2
votes

Hello i'm having some trouble in displaying multiple pushpins on maps. So far i've tried adding either individual pushpins or first putting them in a MapLayer and then adding the maplayer to the map but i still only get the last pushpin that i created. Code sample here:

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);
3
I can see no reason why that won't work. Can you please show a complete repro. - Matt Lacey

3 Answers

2
votes

The example code that you provided sets pin1's location twice instead of setting pin2's location.

pin1.Location = geo1;

should be

pin2.Location = geo1;
1
votes
    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);
0
votes

Try this,

Pushpin pin2 = new Pushpin();
GeoCoordinate geo1 = new GeoCoordinate();
geo1.Latitude = 45.9074417114258;
geo1.Longitude = 15.8677000045776;
pin2.Location = geo1;
layer.Children.Add(pin2);