您好我正在使用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;
}
答案 0 :(得分:1)
由于他们没有任何nuget包或dll直接引用,您需要下载ClusteringLayer
等特定类source code。 PushPin
将相关.cs文件或项目本身添加到您的计算机,并在您的Windows Phone项目中添加此项目的引用,以获取ClusteringLayer
和PushPin
类。
请参阅ClusteringLayer
课程的以下屏幕截图。对于其他类,只需将解决方案导入visual studio,您将看到所有类的源代码。 BTW,ClusteringLayer
构造函数需要在集群中至少有一个参数。
我建议您下载源代码,并从源代码中的示例中熟悉它的用法。