【问题标题】:windows phone 8.1 bing maps clusteringwindows phone 8.1 bing 地图聚类
【发布时间】:2015-05-20 18:00:23
【问题描述】:

您好,我正在使用this 链接中描述的 Windows 地图控件,并且我有一个带有多个 MapOverlays 的 MapLayer,地图上有不同的 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;
    }

【问题讨论】:

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


    【解决方案1】:

    由于他们没有任何 nuget 包或 dll 可直接引用,因此您需要将特定类的 source code 与相关的 .cs 文件或项目本身下载到您的机器上,例如 ClusteringLayerPushPin,然后在您的 windows phone 项目中添加此项目的引用以获取 ClusteringLayerPushPin 类。

    查看ClusteringLayer 类的以下屏幕截图。对于其他类,只需将解决方案导入 Visual Studio,您将看到所有类的源代码。顺便说一句,ClusteringLayer 构造函数在集群中至少需要一个参数。

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

    【讨论】:

    • 这些类的源代码在哪里,我找不到。我已经下载了解决方案,但 wp8.1 示例无法正常工作。它说该项目与当前版本的vs不兼容
    • 我现在会检查它,我会告诉你是否有效
    • 你好,我不能添加项目作为参考。我已将课程添加到我的项目中,但它需要更多课程
    • 所以,只需添加它们。你被困在哪里了? :)
    • 尝试在那里运行示例,看看是否有任何发现。如果您没有看到任何东西,那么您可能没有连接到互联网,因此地图上什么也没有。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多