自2018年10月18日起,高德开发者论坛除车机板块外,其他板块将停止发帖与维护,如您有使用问题请 提交工单 联系我们,感谢您的理解。

查看: 502|回复: 0
打印 上一主题 下一主题

[报错] AMap.MarkerClusterer is not a constructor

[复制链接]
最佳答案
0 

1

主题

1

帖子

11

积分

新手上路

Rank: 1

积分
11
跳转到指定楼层
楼主
发表于 2018-9-13 20:41:34 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
发表帖子
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
});




回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|小黑屋|高德开发者论坛

Copyright ©2014 高德开发者论坛.All Rights Reserved |京ICP证070711号

意见反馈 常见问题 服务条款 联系我们
快速回复 返回顶部 返回列表