0
votes

I use this code to add custom marker to BING map control. The Map component can't draw Image(), but text works fine. Am I wrong?

private void AddMarkerToMap(double Latitude, double Longitude, string Name)
{
    Image markerImg = new Image { Width = 63, Height = 46 };
    Uri imgUri = new Uri("Images/GeoPin.png", UriKind.RelativeOrAbsolute);
    if (imgUri == null)
    {
        throw new Exception("Image can't be find");
    }
    markerImg.Source = new BitmapImage(imgUri);
    markerImg.Tag = Name;
    //markerImg.Tap += delegate
    //{
    //    // handle tap
    //};

    var overlay = new MapOverlay
    {
        PositionOrigin = new Point(0.5, 0.5),
        GeoCoordinate = new GeoCoordinate(Latitude, Longitude),
        Content = markerImg,
        //Content = Name,
    };

    var mapLayer = new MapLayer { overlay };
    MyMap.Layers.Add(mapLayer);
}
3
Are you talking about the tooltip or the mapmarker?Kulasangar
I need a marker on the map, which is Imagealex

3 Answers

0
votes

If you want to add a pin to Map, use MapIcon class. This can display images as well as text.

private void AddMapIcon()
{
    MapIcon MapIcon1 = new MapIcon();
    MapIcon1.Location = new Geopoint(new BasicGeoposition() { Latitude = 47.620, Longitude = -122.349 });
    MapIcon1.NormalizedAnchorPoint = new Point(0.5, 1.0);
    MapIcon1.Title = "Space Needle";
    MapIcon1.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/customicon.png"));
    MapControl1.MapElements.Add(MapIcon1);
}
0
votes

Does MapIcon present in Windows Phone 8 SDK?

0
votes

You could use the Phone.Controls.Toolkit in order to have a custom Pushpin as an image on your map.

Reference: Image as pushpin on maps - Windows phone 8