2

您好,我在地图上显示多个图钉时遇到了一些问题。到目前为止,我已经尝试添加单个图钉或首先将它们放入 MapLayer 中,然后将 maplayer 添加到地图中,但我仍然只得到我创建的最后一个图钉。代码示例在这里:

MapLayer layer = new MapLayer();
                Pushpin pin1 = new Pushpin();
                GeoCoordinate geo= new GeoCoordinate();
                geo.Latitude = 45.8074417114258 ;
                geo.Longitude = 15.9677000045776;
                pin1.Location = geo;
                layer.Children.Add(pin1);
                Pushpin pin2 = new Pushpin();
                GeoCoordinate geo1 = new GeoCoordinate();
                geo1.Latitude = 45.9074417114258;
                geo1.Longitude = 15.8677000045776;
                pin1.Location = geo1;
                layer.Children.Add(pin2);

                map1.Children.Add(layer);
4

3 回答 3

2

您提供的示例代码设置了 pin1 的位置两次,而不是设置 pin2 的位置。

pin1.Location = geo1;

应该

pin2.Location = geo1;
于 2012-05-23T12:56:18.870 回答
1
    Instead of doing this, create no of Pushpin objects  you want...
    and set the location of the pushpin..try this

    Pushpin pushpin1 = new Pushpin();
    pushpin1.Location = new GeoCoordinate(21.7679, 78.8718);

    Pushpin pushpin = new Pushpin();
    pushpin1.Location = new GeoCoordinate(45.8074417114258, 15.8677000045776);

    map1.Children.Add(pushpin1);
    map1.Children.Add(pushpin2);
于 2012-11-26T07:59:56.983 回答
0

尝试这个,

Pushpin pin2 = new Pushpin();
GeoCoordinate geo1 = new GeoCoordinate();
geo1.Latitude = 45.9074417114258;
geo1.Longitude = 15.8677000045776;
pin2.Location = geo1;
layer.Children.Add(pin2);
于 2012-08-01T08:17:06.787 回答