4

如果您在同一地理位置的“伦敦”上有 2 个图钉,API 中是否有任何东西可以将它们分开以便它们都可见?

我只能在他们的旧地图点 API 上找到文档,该 API 有 PreventIconCollisions,这就是我想要的,但在新 API 中看不到任何对此的引用。

我正在使用 JavaScript API。

4

2 回答 2

0

因此,如果我理解正确,您在同一位置有类似的信息,这是正确的吗?

为了显示这两个信息,您将有两个选项:

  1. 使用适当的方式合并文本框中的信息以在此 ui 元素中显示信息(例如,使用您自己的选项卡式信息框)
  2. 当您处于一定的缩放级别时手动对点进行去簇

没有默认属性来设置它,在许多图钉上这样做真的很麻烦,但在主要思想中,你必须:检测 viewchangeend 事件,如果你处于一定的缩放级别(或更高的缩放级别) 然后你正在对它们进行去簇(我称之为 decluter 附近的图钉)。

// Bind pushpin mouseover.
    Microsoft.Maps.Events.addHandler(pin, 'mouseover', function (e) {
        var currentPin = e.target;
        currentPin.setOptions({ visible: false });
        var currentLocation = currentPin.getLocation().clone();

        var currentPoint = bmGlobals.geo.map.tryLocationToPixel(currentLocation);
        if (currentPin.associatedCluster.length == 2) {
            // Display the first pushpin
            var pinA = createPin(currentPin.associatedCluster[0]);
            var locA = bmGlobals.geo.map.tryPixelToLocation(new Microsoft.Maps.Point(currentPoint.x - pinA.getWidth(), currentPoint.y));
            pinA.setLocation(locA);
            bmGlobals.geo.layerClusteredPin.push(pinA);

            // Display the second pushpin
            var pinB = createPin(currentPin.associatedCluster[1]);
            var locB = bmGlobals.geo.map.tryPixelToLocation(new Microsoft.Maps.Point(currentPoint.x + pinB.getWidth(), currentPoint.y));
            pinB.setLocation(locB);
            bmGlobals.geo.layerClusteredPin.push(pinB);
        }
    });

我将尝试为此编写一个 bing 地图模块,但事实上,您必须获取集群图钉(或您自己的具有两个关联数据对象的图钉),然后您必须根据在客户端渲染。

于 2013-01-30T06:46:48.650 回答
0

我知道这个问题真的很老了,但是如果有人正在寻找类似的东西(对引脚进行聚类),这是一个好的开始:http ://rtsinani.github.io/PinClusterer/

于 2014-08-20T15:52:40.993 回答