|
发表帖子
API/SDK版本号: |
1.4.10 |
产品: |
2D地图 |
手机型号: |
|
使用接口: |
点集合-AMap.MarkerClusterer |
根据示例,创建点聚合时报错: Uncaught TypeError: AMap.MarkerClusterer is not a constructor
代码如下
for(...){
markers.push(
new AMap.Marker({
map: map,
position: [lnghts[i].surveyLongitude, lnghts[i].surveyLatitude],
icon: icon,
offset: new AMap.Pixel(-12, -36)
})
);
}
var count = markers.length;
var _renderCluserMarker = function(context) {
var factor = Math.pow(context.count / count, 1 / 18)
var div = document.createElement('div');
var Hue = 180 - factor * 180;
var bgColor = 'hsla(' + Hue + ',100%,50%,0.7)';
var fontColor = 'hsla(' + Hue + ',100%,20%,1)';
var borderColor = 'hsla(' + Hue + ',100%,40%,1)';
var shadowColor = 'hsla(' + Hue + ',100%,50%,1)';
div.style.backgroundColor = bgColor
var size = Math.round(30 + Math.pow(context.count / count, 1 / 5) * 20);
div.style.width = div.style.height = size + 'px';
div.style.border = 'solid 1px ' + borderColor;
div.style.borderRadius = size / 2 + 'px';
div.style.boxShadow = '0 0 1px ' + shadowColor;
div.innerHTML = context.count;
div.style.lineHeight = size + 'px';
div.style.color = fontColor;
div.style.fontSize = '14px';
div.style.textAlign = 'center';
context.marker.setOffset(new AMap.Pixel(-size / 2, -size / 2));
context.marker.setContent(div)
}
var cluster = new AMap.MarkerClusterer(map, markers, {
gridSize: 80,
renderCluserMarker: _renderCluserMarker
});
|
|