如何解析XML文件的标记位置和在地图上绘制 [英] How to parse xml file for marker locations and plot on map
问题描述
我试图从xml文件中读取点,而不是像下面的例子那样从javascript读取点。
但它不是为我工作。我创建了一个包含以下内容的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.
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屋!