windows phone 8.1 bing maps clustering

时间:2015-05-19 15:38:16

标签: c# windows-phone-8 bing-maps

您好我正在使用this链接中描述的Windows地图控件,我有一个MapLayer,其中多个MapOverlay在地图上有不同的pois。我想做集群的事情。我尝试this,但没有ClusteringLayer,也没有Pushpin。我该如何进行聚类?

var cluster = new ClusteringLayer();

layer = new ClusteringLayer(Mymap)
        {
            ClusterRadius = 10,
            ClusterType = ClusteringType.Grid
        };

//Add event handlers to create the pushpins 
layer.CreateClusteredItemPushpin += CreateClusteredItemPushpin1;
layer.CreateItemPushpin+=layer_CreateItemPushpin;

    private MapOverlay layer_CreateItemPushpin(object item, ClusteredPoint clusterInfo)
    {
        var x = clusterInfo.Location;
        var poi = new BuildingPoi { Coordinate = x, Buid = _selectedBuild };
        var imagePoiLocation = new Image
        {
            Source = new BitmapImage(new Uri("/Assets/MapPin.png", UriKind.Relative)),
            DataContext = poi
        };

        var over = new MapOverlay();

        imagePoiLocation.Tap += loadClickedBuilding;
        over.Content = imagePoiLocation;
        over.PositionOrigin = new Point(0.5, 0.5);
        over.GeoCoordinate = new GeoCoordinate(x.Latitude, x.Longitude);

        return over;
    }

    private MapOverlay CreateClusteredItemPushpin1(ClusteredPoint clusterInfo)
    {
        var x = clusterInfo.Location;
        var poi = new BuildingPoi { Coordinate = x, Buid = _selectedBuild };
        var imagePoiLocation = new Image
        {
            Source = new BitmapImage(new Uri("/Assets/MapPin.png", UriKind.Relative)),
            DataContext = poi
        };

        var over = new MapOverlay();

        imagePoiLocation.Tap += loadClickedBuilding;
        over.Content = imagePoiLocation;
        over.PositionOrigin = new Point(0.5, 0.5);
        over.GeoCoordinate = new GeoCoordinate(x.Latitude, x.Longitude);

        return over;
    }

1 个答案:

答案 0 :(得分:1)

由于他们没有任何nuget包或dll直接引用,您需要下载ClusteringLayer等特定类source codePushPin将相关.cs文件或项目本身添加到您的计算机,并在您的Windows Phone项目中添加此项目的引用,以获取ClusteringLayerPushPin类。

请参阅ClusteringLayer课程的以下屏幕截图。对于其他类,只需将解决方案导入visual studio,您将看到所有类的源代码。 BTW,ClusteringLayer构造函数需要在集群中至少有一个参数。

我建议您下载源代码,并从源代码中的示例中熟悉它的用法。

enter image description here