如何解析XML文件的标记位置和在地图上绘制 [英] How to parse xml file for marker locations and plot on map

查看:121
本文介绍了如何解析XML文件的标记位置和在地图上绘制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从xml文件中读取点,而不是像下面的例子那样从javascript读取点。



https://google-developers.appspot.com/maps/documentation/javascript/examples/marker-animations-iteration



但它不是为我工作。我创建了一个包含以下内容的XML文件:

 <?xml version =1.0encoding =UTF-8?> ; 
< companies>
< company>
< lat> 52.511467< / lat>
< lng> 13.447179< / lng>
< / company>
< company>
< lat> 52.549061< / lat>
< lng> 13.422975< / lng>
< / company>
< company>
< lat> 52.497622< / lat>
< lng> 13.396110< / lng>
< / company>
< company>
< lat> 52.517683< / lat>
< lng> 13.394393< / lng>
< / company>
< / companies>

但我无法在google maps v3上显示点数。有没有人有一个解析XML文件的坐标,然后在地图上显示它们的例子?

解决方案

辉煌 - 非常感谢提示!
上面的代码仍然存在一个小错误:

替换

lockquote

markers.setMap(map);

by


marker.setMap(map);

...那就行了!


I am trying to read points from an xml file rather than from javascript as in the example below.

https://google-developers.appspot.com/maps/documentation/javascript/examples/marker-animations-iteration

But it is not working for me. I have created an xml file containing:

<?xml version="1.0" encoding="UTF-8"?>
<companies>
    <company>
        <lat>52.511467</lat>
        <lng>13.447179</lng>
    </company>
    <company>
        <lat>52.549061</lat>
        <lng>13.422975</lng>
    </company>
    <company>
        <lat>52.497622</lat>
        <lng>13.396110</lng>
    </company>
    <company>
        <lat>52.517683</lat>
        <lng>13.394393</lng>
    </company>
</companies> 

But I cannot get the points displaying on google maps v3. Does anyone have an example of parsing an xml file for coordinates and then displaying them on a map?

解决方案

Brilliant - thanks a lot for the hint! One little mistake is still in the above code:

replace

markers.setMap(map);

by

marker.setMap(map);

...then it'll work!

这篇关于如何解析XML文件的标记位置和在地图上绘制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆