【问题标题】:How to display certain amounts of PushPins on a Bing Map according to the zoom level?如何根据缩放级别在 Bing 地图上显示一定数量的 PushPins?
【发布时间】:2013-03-12 16:43:33
【问题描述】:

在我的 Web 应用程序中,PushPin 表示位于某个区域的设备,它根据两个操作在 Bing 地图上显示 PushPin:

  • 一个是当用户想要显示所有设备时 已注册。

  • 第二个是当服务器向网站发送信号时 必须显示特定设备。

问题是一个地区有几个设备,当地图缩小到 5 级时,它们看起来都很乱。

有没有办法根据缩放级别限制 Bing 地图上显示的现有 PushPins 的数量?就像在第 5 级只显示一个 PushPin 一样,在更高的缩放级别增加显示的数量,因此在第 15 级显示所有现有的 PushPin。

我尝试了 EnableShapeDisplayThreshold 方法,但似乎只适用于折线和多边形,而不适用于 PushPins。

任何帮助将不胜感激。提前致谢。

【问题讨论】:

    标签: javascript bing-maps pushpin


    【解决方案1】:

    您要做的是使用所谓的聚类,它根据缩放级别和当前地图视图对标记(图钉)进行分组。

    参考:

    根据您当前使用的方法 (EnableShapeDisplayThreshold),我假设您使用的是 v6.3,因此您应该能够使用 VEShapeLayer.SetClusteringConfiguration() 方法:

    http://msdn.microsoft.com/en-us/library/cc966930.aspx

    示例代码:

    在这里行动:http://msdn.microsoft.com/en-us/library/cc980909.aspx

    【讨论】:

    • 这正是我想要的。谢谢。我有一个简单的问题,有没有办法在集群上设置自定义文本?并传递集群选项,我是否只初始化像 VECustomIconSpecification icon = new VECustomIconSpecification(); icon.Image = 'myIcon.png'; VEClusteringOptions options = new VEClusteringOptions(icon, null); 这样的对象?
    • 我试图更改图标,但它似乎不起作用,我正在这样做var custom = "<div style='font-size:12px;font-weight:bold;border:solid 2px Black;background-color:Aqua;width:50px;'>Custom</div>"; var icon = new VECustomIconSpecification(); icon.CustomHTML = custom; icon.Image = '../Content/Image/icons/pin2.png'; var options = new VEClusteringOptions(icon, null);,基于this 链接。这是正确的吗?
    猜你喜欢
    • 2014-02-21
    • 2021-04-18
    • 1970-01-01
    • 2018-10-07
    • 1970-01-01
    • 2021-05-29
    • 2012-08-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多