HERE Maps JS API v3:监听 `clusteringend` 事件
HERE Maps JS API v3: listen to `clusteringend` event
有没有什么方便的方法判断聚类进程是否有finished/ended?我似乎没有在 the clustering provider 中看到任何我可以收听的本地 clusteringend
事件。
自从过去几天以来,这个问题又让我头疼了。 =(
是的,随便吧。我没有等待一些 HERE 地图菜鸟的令人失望的回答,而是尝试解决我的问题并做出了一些奇怪的事情(尚未对其进行彻底测试,但到目前为止它运行良好):
var
/*
* Work "listen-to-clusteringend-event-issue" around.
*/
processedNoisePointCounter = 0,
incrementProcessedNoisePoint = function () {
processedNoisePointCounter++;
if (processedNoisePointCounter === dataPoints.length) {
map.dispatchEvent('clusteringend');
}
},
clusteredDataProvider = new H.clustering.Provider([]),
defaultTheme = clusteredDataProvider.getTheme(),
customTheme = {
/**
*
* @implements {H.clustering.ITheme.getClusterPresentation}
*/
getClusterPresentation: function (cluster) {
var clusterMarker = defaultTheme.getClusterPresentation.call(defaultTheme, cluster);
cluster.forEachEntry(function (entry) {
if (!entry.isCluster()) {
incrementProcessedNoisePoint();
}
});
return clusterMarker;
},
/**
*
* @implements {H.clustering.ITheme.getNoisePresentation}
*/
getNoisePresentation: function (noisePoint) {
var noiseMarker = defaultTheme.getNoisePresentation.call(defaultTheme, noisePoint);
incrementProcessedNoisePoint();
return noiseMarker;
}
};
clusteredDataProvider.setTheme(customTheme);
clusteredDataProvider.setDataPoints(dataPoints);
var layer = new H.map.layer.ObjectLayer(clusteredDataProvider);
map.addLayer(layer);
map.addEventListener('clusteringend', function () {
var message = 'Clustering allegedly ends. ;)';
console.log(message);
window.alert(message);
});
JSFiddle 可用 here。
有没有什么方便的方法判断聚类进程是否有finished/ended?我似乎没有在 the clustering provider 中看到任何我可以收听的本地 clusteringend
事件。
自从过去几天以来,这个问题又让我头疼了。 =(
是的,随便吧。我没有等待一些 HERE 地图菜鸟的令人失望的回答,而是尝试解决我的问题并做出了一些奇怪的事情(尚未对其进行彻底测试,但到目前为止它运行良好):
var
/*
* Work "listen-to-clusteringend-event-issue" around.
*/
processedNoisePointCounter = 0,
incrementProcessedNoisePoint = function () {
processedNoisePointCounter++;
if (processedNoisePointCounter === dataPoints.length) {
map.dispatchEvent('clusteringend');
}
},
clusteredDataProvider = new H.clustering.Provider([]),
defaultTheme = clusteredDataProvider.getTheme(),
customTheme = {
/**
*
* @implements {H.clustering.ITheme.getClusterPresentation}
*/
getClusterPresentation: function (cluster) {
var clusterMarker = defaultTheme.getClusterPresentation.call(defaultTheme, cluster);
cluster.forEachEntry(function (entry) {
if (!entry.isCluster()) {
incrementProcessedNoisePoint();
}
});
return clusterMarker;
},
/**
*
* @implements {H.clustering.ITheme.getNoisePresentation}
*/
getNoisePresentation: function (noisePoint) {
var noiseMarker = defaultTheme.getNoisePresentation.call(defaultTheme, noisePoint);
incrementProcessedNoisePoint();
return noiseMarker;
}
};
clusteredDataProvider.setTheme(customTheme);
clusteredDataProvider.setDataPoints(dataPoints);
var layer = new H.map.layer.ObjectLayer(clusteredDataProvider);
map.addLayer(layer);
map.addEventListener('clusteringend', function () {
var message = 'Clustering allegedly ends. ;)';
console.log(message);
window.alert(message);
});
JSFiddle 可用 here。