自定义了地图标点,然后想添加一个点聚合功能,聚合功能可以实现,但是自定义的标点还在地图上,
var data_point_x = 116.306771,
data_point_y = 31.653254;
var cluster, markers = [],points=[];
var map = new AMap.Map("areaMap", {
resizeEnable: true,
center: [data_point_x, data_point_y],
zoom: 9,
pitch : 65,
viewMode : '3D',
mapStyle : commonService.mapStyle
});
for(var i=0; i<geoCoordMap.length; i++) {
points.push({lnglat:[geoCoordMap[i].ziyuan_coord_x,geoCoordMap[i].ziyuan_coord_y]});
markers.push(new AMap.Marker({
position: [geoCoordMap[i].ziyuan_coord_x,geoCoordMap[i].ziyuan_coord_y],
content: '<div style="background-color: hsla(180, 100%, 50%, 0.7); height: 24px; width: 24px; border: 1px solid hsl(180, 100%, 40%); border-radius: 12px; box-shadow: hsl(180, 100%, 50%) 0px 0px 1px;">123321</div>',
offset: new AMap.Pixel(-15, -15)
}));
map.add(markers);
};
var count = markers.length;
var _renderClusterMarker = 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)
};
cluster = new AMap.MarkerClusterer(map, points, {
gridSize: 80,
renderClusterMarker: _renderClusterMarker
});