如何从 GGeoXml 对象获取 KML 数据

发布于 2024-08-17 03:40:56 字数 376 浏览 11 评论 0原文

我使用以下代码将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

蓦然回首 2024-08-24 03:40:56

您可以从 GGeoXML 获取 KML,

窗口中有一个变量,

geoXml = new GGeoXml("http://mapgadgets.googlepages.com/cta.kml",
                         function(){
                              geoXml.getKml(
                                function(a){
                                  myKml = a;
                                  alert(myKml);
                                });} );

请在此处尝试:
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

geoXml = new GGeoXml("http://mapgadgets.googlepages.com/cta.kml",
                         function(){
                              geoXml.getKml(
                                function(a){
                                  myKml = a;
                                  alert(myKml);
                                });} );

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

半仙 2024-08-24 03:40:56

您无法通过 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.).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文