如果您在同一地理位置的“伦敦”上有 2 个图钉,API 中是否有任何东西可以将它们分开以便它们都可见?
我只能在他们的旧地图点 API 上找到文档,该 API 有 PreventIconCollisions,这就是我想要的,但在新 API 中看不到任何对此的引用。
我正在使用 JavaScript API。
因此,如果我理解正确,您在同一位置有类似的信息,这是正确的吗?
为了显示这两个信息,您将有两个选项:
没有默认属性来设置它,在许多图钉上这样做真的很麻烦,但在主要思想中,你必须:检测 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 地图模块,但事实上,您必须获取集群图钉(或您自己的具有两个关联数据对象的图钉),然后您必须根据在客户端渲染。
我知道这个问题真的很老了,但是如果有人正在寻找类似的东西(对引脚进行聚类),这是一个好的开始:http ://rtsinani.github.io/PinClusterer/