我在客户端使用Bing Maps有问题。
clusteredPinCallback
的映射方法,该方法可以访问数组,并且每个cluster grid
中都有所有标记。text
,title
等,但没有正确设置。
const extendedPins = pins.map((pinItem, index) => {
const options = {
icon: 'https://www.bingmapsportal.com/Content/images/poi_custom.png',
title: 123,
text: 123
};
return new Microsoft.Maps.Pushpin(pin, options);
});
clusterLayer = new Microsoft.Maps.ClusterLayer(extendedPins, {
clusteredPinCallback: createCustomClusteredPin,
gridSize: 80
});
map.layers.insert(clusterLayer);
});
const createCustomClusteredPin = (cluster) => {
console.warn(cluster)
}
似乎有两个问题:
图钉的文本和标题必须为字符串,而您要输入数字。
在clusteredPinCallback
中,已经创建了集群图钉,因此您可以通过setOptions
调用对其进行自定义。
尝试使用此示例替换示例中的相同功能:
function createCustomClusteredPin(cluster) {
cluster.setOptions({
icon: 'https://www.bingmapsportal.com/Content/images/poi_custom.png',
title: "123",
text: "123"
});
}