获取 Google 地图标记的坐标
我正在创建一个数据库,其中包含我所在地区所有公交车站的名称和坐标。我已将所有名称存储在数据库中,现在我需要添加坐标。我正在尝试获取一个网站,其中包含所有这些内容作为谷歌地图上的地标。在我看来,它们是从本地服务器生成的,然后添加到地图中。但是我无法准确找到在哪里查询服务器的坐标。
我希望通过使用屏幕刮刀来收集这些坐标。但是,除非我能够在源代码中找到创建坐标的位置,否则这似乎是不可能的。我当然可以手动搜索和收集所有这些地标,但这将非常耗时。所以我希望这里有人能帮助我。
这是我正在尝试抓取的网站。地标由蓝色巴士标志标记:
您还可以通过在搜索字段中输入停靠点名称来获取单个地标的坐标并按下“Vis i kart”按钮。
我希望有人能帮助我解决这个问题。
I am creating a databse containing the names and coordinates of all bus stops in my local area. I have all the names stored in my database, and now I need to add the coordinates. I am trying to get these of a website that contains them all as placemarks on a Google Map. It seems to me like they are being generated from a local server, and then added to the map. However I am unable to find exactly where the server is queried for the coordinates.
I am hoping to collect these coordinates through the use of a screen scraper. However unless I am able to find where in the source code the coordinates are created this seems to be impossible. I can of course search and collect all these placemarks manually, but that will be very time consuming. So I am hoping that someone in here can help me.
This is the website I am trying to scrape. The placemarks are marked by the blue bus sign:
You can also get the coordinates of a single placemark by writing the name of the stop in the search field and pushing the "Vis i kart" button.
I hope someone can help me with this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在检查 Firebug 时,您提到的站点似乎正在通过简单的 AJAX 请求获取 XML 格式的数据,例如:
(x1, y1), (x2, y2) 参数定义视口的(经度, 纬度) 参数。每次拖动地图时,都会发出一个新的 AJAX 请求,该请求会返回新的数据。
这是来自 AJAX 请求的示例响应:
请注意,
x
属性定义经度,而y
属性定义纬度。除了技术答案之外,我建议在抓取此类数据之前寻求许可。
On checking with Firebug, it appears that the site you mentioned is getting the data in XML format with simple AJAX requests such as:
The (x1, y1), (x2, y2) parameters define the (longitude, latitude) parameters of the viewport. Everytime the map is dragged, a new AJAX request is issued, which returns fresh data.
This is a sample response from the AJAX request:
Note that the
x
attribute is defining the longitude, while they
attribute is defining the latitude.Apart from the technical answer, I would suggest seeking permission before scraping such data.
检查此页面的源代码。谷歌地图显示为空白。然后通过代码添加标记。最有可能的坐标是在页面或引用的 JS 中硬编码的。或者可能是通过 Ajax 进行页面请求。同样,您将在源代码中看到它。
examine the source codes of this page. Google map comes blank from google. Then markers are added by code. Most probably coordinates are hardcoded in page or referenced JS. Or may be page requests them via Ajax. Again, you will see it in source code.