高德点聚合的demo直接复制下来,报错。
- 39行少了http头,添加上
<script src="http://a.amap.com/jsapi_demos/static/china.js"></script>
- 40行改为自己的ak
<script type="text/javascript"
src="https://webapi.amap.com/maps?v=1.4.15&key=你的key&plugin=AMap.MarkerClusterer"></script>
注意key后面的plugin不能删掉,删掉的话报错AMap.MarkerClusterer is not a constructor
如果报错了,找到他,改为
map.plugin(["AMap.MarkerClusterer"],function() {
cluster = new AMap.MarkerClusterer(map, markers, {
styles:sts
});
});