开发者

silverlight bing maps pushpin question

I'm trying to use the microsoft_maps_mapcontrol. I see how one could create a pushpin and the lat long location... but i can't figure out how to instead use an image in place of that pushpin. doesn't look like pushpin will allow using a different image. So, that being the case how do you create an image and then wire it to the proper spot. Once wired can will i be able to use an event for when that image is clicked on.

thanks shannon


added 3/2/2010

I've looked at the example given at http://www.microsoft.com/maps/isdk/silverlightbeta/#MapControlInteractiveSdk.Tutorials.UIElements.Media.TutorialPositionPointMedia

and i must not be converting something correctly to vb.

Here is there code

 Image image = new Image();
  image.Source = new BitmapImage(new Uri(ImageUriValue.Text, UriKind.RelativeOrAbsolute));
        double opacity;
        if (double.TryParse(OpacityText.Text, out opacity))
        {
            image.Opacity = opacity;
        }
        image.ImageFailed += MediaFailed;

  Point point = GetPoint();
  Canvas.SetLeft(image, point.X);
  Canvas.SetTop(image, point.Y);
  myCanvas.Children.Add(image);

  element = image;

and what i converted it to

        Dim image As New Image()
    image.Source = New BitmapImage(New Uri("\Images\1.png", UriKind.RelativeOrAbsolute))

    Canvas.SetLeft(image, 100)
    Canvas.SetTop(ima开发者_开发知识库ge, 100)
    myCanvas.Children.Add(image)

    element = image

Hopefully that helps in spotting what i'm not doing correctly. thanks shannon


Here's a code snippet that should show you how to add an image.

public void addImageToMap()
{
    MapLayer imageLayer = new MapLayer();

    Image image = new Image();
    //Define the URI location of the image
    image.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri("myimage.png", UriKind.Relative));
    //Define the image display properties
    image.Opacity = 0.8;
    image.Stretch = System.Windows.Media.Stretch.None;
    //The map location to place the image at
    Location location = new Location() { Latitude = -45, Longitude = 122 };
    //Center the image around the location specified
    PositionOrigin position = PositionOrigin.Center;

    //Add the image to the defined map layer
    imageLayer.AddChild(image, location, position);
    //Add the image layer to the map
    TestMap.Children.Add(imageLayer);
}

http://msdn.microsoft.com/en-us/library/ee681895.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜