Bing地图图像叠加

时间:2015-01-10 19:12:29

标签: bing-maps

我一直关注这篇关于使用图像叠加来制作地图的文章:

http://blogs.msdn.com/b/bingdevcenter/archive/2014/04/04/image-overlays-with-bing-maps-native.aspx

我现在想要的是能够在此图像的顶部添加多边形/折线。让我们举例说,我们使用以下代码:

(From here: http://blogs.bing.com/maps/2014/01/23/make-clickable-shapes-in-the-native-bing-maps-control/)


private void MyMapLoaded(object sender, RoutedEventArgs e)
{
//Add a shape layer to the map
    shapeLayer = new MapShapeLayer();
    MyMap.ShapeLayers.Add(shapeLayer);

//Create mock data points
    var locs = new LocationCollection();

    locs.Add(new Location(coordinates that are over the image));
    locs.Add(new Location(coordinates that are over the image));
    locs.Add(new Location(coordinates that are over the image));

//Create test polygon
    var polygon = new MapPolygon();
    polygon.Locations = locs;
    polygon.FillColor = Colors.Red;


    shapeLayer.Shapes.Add(polygon);

    var locs2 = new LocationCollection();
    locs2.Add(new Location(20, 20));
    locs2.Add(new Location(40, 40));
    locs2.Add(new Location(50, 20));

//Create test polyline
    var polyline = new MapPolyline();
    polyline.Locations = locs2;
    polyline.Width = 5;
    polyline.Color = Colors.Blue;



//Add the shape to the map
    shapeLayer.Shapes.Add(polyline);
}

问题是多边形/折线总是出现在图像下方。 ShapeLayer具有z-index的属性,但它没有帮助。有没有办法让我的多边形始终处于最佳状态?

1 个答案:

答案 0 :(得分:0)

不确定为什么要这样做,但是您将无法在添加为地图子项的用户控件上方显示MapPolygon。也就是说,您可以创建WPF多边形并添加它们。您可以做的是创建一个自定义用户控件,将图像叠加功能与以下内容结合起来:http://blogs.msdn.com/b/bingdevcenter/archive/2014/03/25/custom-shapes-in-windows-store-apps-c.aspx