简体   繁体   English

在Artem Google地图上添加多个标记

[英]Add Multiple markers on Artem Google Maps

I want to show multiple markers on based of longitudes and latitudes in artem google maps . 我想在artem谷歌地图中基于经度和纬度显示多个标记。 currently i can show only one address based on longitude and latitude on map. 目前,我只能在地图上显示基于经度和纬度的一个地址。

I am using an xml file to store the latitude and longitude 我正在使用xml文件存储纬度和经度

<?xml version="1.0" encoding="utf-8"?>
<Mark>
  <Position>
    <ID>1</ID>
    <Latitude>37.2808</Latitude>
    <Longitude>49.5832</Longitude>
    <Name>A</Name>
</Position>
</Mark>

I use this code 我用这个代码

XDocument xmlDoc = XDocument.Load(Server.MapPath("~/App_Data/Map.xml"));
var query = from st in xmlDoc.Descendants("Position")
                        select st;

    foreach (var p in query)
    {
          Marker mark = new Marker();
                    mark.Position = new LatLng(double.Parse(p.Element("Latitude").Value), double.Parse(p.Element("Longitude").Value));
                    mark.Title = p.Element("Name").Value;
                    mark.Info = p.Element("Name").Value;
                    GoogleMap1.Markers.Add(mark);
    }

You can also add a list of markers on your maps ... you just need to find the way how to read them from you xml to proper form below..., you also have some other options in Marker constuctor... 您还可以在地图上添加标记列表...您只需要找到如何从xml到下面的正确格式读取标记的方式...,标记构造器中还有其他一些选择...

List<Marker> markers = new List<Marker>()
{
    new Marker { Position = new LatLng(42.1229, 24.7879), Title="A" },
    new Marker { Position =  new LatLng(42.7, 23.3), Title="B" },
    new Marker { Position =  new LatLng(43.1, 22.3), Title="C" }
};

GoogleMap1.Markers.AddRange(markers);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM