Question

does anyone know how to put a pushpin on Windows Phone 8 maps API? I find only code to add a pushpin to a bing map.. I prefer only XAML code, if possible. Thanks

Was it helpful?

Solution

This is what I use.. the commented out code will give you a round marker, the default pushpin is squarish..

      <Grid x:Name="ContentPanel" Margin="12,0,12,0">
            <maps:Map x:Name="MapControl">
            </maps:Map>
        </Grid>

   private void DisplayMapPoint()
    {
        MapControl.Layers.Clear();

        var MyGeo = new GeoCoordinate(_Latitude, _Longitude);
            MapControl.Center = MyGeo;
            MapControl.ZoomLevel = 14;
            DrawMapMarker();
    }

    private void DrawMapMarker()
    {
        var Overlay = new MapOverlay
        {
            GeoCoordinate = MapControl.Center,
            //Content = new Ellipse
            //{
            //    Fill = new SolidColorBrush(Colors.Red),
            //    Width = 40,
            //    Height = 40
            //}
            Content = new Pushpin
                      {
                          GeoCoordinate = MapControl.Center,
                          Background = new SolidColorBrush(Colors.Red),
                          Content = _SiteName
                      }
        };

        var Layer = new MapLayer {Overlay};
        MapControl.Layers.Add(Layer);
    }

This link may also help: http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj207037(v=vs.105).aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top