如何从 GGeoXml 对象获取 KML 数据
我使用以下代码将 KML 文件加载到谷歌地图对象中:
map = new GMap2(document.getElementById("map_canvas"));
geoXml = new GGeoXml(kml);
GEvent.addListener(geoXml, "load", function() {
geoXml.gotoDefaultViewport(map);
// I would like to read the KML contents here
});
map.addOverlay(geoXml);
// ...
我想从 KML 文件中读取地标并将其显示在列表中。我知道我需要的信息正在传输到浏览器,但我不知道如何访问它。
I load an KML file into a google map object using the following code:
map = new GMap2(document.getElementById("map_canvas"));
geoXml = new GGeoXml(kml);
GEvent.addListener(geoXml, "load", function() {
geoXml.gotoDefaultViewport(map);
// I would like to read the KML contents here
});
map.addOverlay(geoXml);
// ...
I would like to read the placemarks from the KML file and display them in a list. I know that the information I need is being transferred to the browser but I don't know how to access it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以从 GGeoXML 获取 KML,
窗口中有一个变量,
请在此处尝试:
http://code.google.com/apis/ajax/playground /?exp=maps#map_geoxml_kml
只需更改为一行,或者,如果您不想使用 GGeoXML 的回调,您可以在加载完成后在其他函数中调用 getKml() ,前提是您的 geoXml不会被消灭
you can get the KML from the GGeoXML
have a variable in window
try it out here:
http://code.google.com/apis/ajax/playground/?exp=maps#map_geoxml_kml
just change to one line , alternatively, if you don't want to use the callback of GGeoXML you can call getKml() in some other function after things have finished loading , provided your geoXml doesn't get wiped out
您无法通过 API 访问它,但数据可在 GGeoXML 对象内的模糊属性中使用。在 Firebug 中查看它,我在这里找到了该信息:
geoxml.$q.ia。自己查看一下,看看您需要的属性(名称、描述等)。
You can't access it through the API, but the data is available in obfuscated properties inside GGeoXML object. Looking at it in Firebug, I found that information here:
geoxml.$q.ia. Look at it yourself to see the properties you need (name, description, etc.).