0

我正在尝试使用 microsoft_maps_mapcontrol。我看到如何创建图钉和经纬度位置......但我无法弄清楚如何使用图像代替该图钉。看起来图钉不允许使用不同的图像。因此,在这种情况下,您如何创建图像然后将其连接到正确的位置。一旦连线,我就可以在单击该图像时使用事件。

谢谢香农


添加于 2010 年 3 月 2 日

我查看了http://www.microsoft.com/maps/isdk/silverlightbeta/#MapControlInteractiveSdk.Tutorials.UIElements.Media.TutorialPositionPointMedia给出的示例

而且我一定不能将某些东西正确地转换为 vb。

这里有代码

 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;

以及我将其转换为的内容

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

    Canvas.SetLeft(image, 100)
    Canvas.SetTop(image, 100)
    myCanvas.Children.Add(image)

    element = image

希望这有助于发现我做错了什么。谢谢香农

4

1 回答 1

1

这是一个代码片段,应该向您展示如何添加图像。

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

于 2010-03-02T04:54:51.403 回答