代码
const map = new BMap.Map('map');
map.centerAndZoom(new BMap.Point(116.404, 39.915), 13);
const data = {
type: 'FeatureCollection',
features: [
{type: 'Feature', geometry: {type: 'Point', coordinates: [116.38, 39.92]}, properties: {}},
{type: 'Feature', geometry: {type: 'Point', coordinates: [116.4, 39.91]}, properties: {}},
{type: 'Feature', geometry: {type: 'Point', coordinates: [116.42, 39.93]}, properties: {}},
{type: 'Feature', geometry: {type: 'Point', coordinates: [116.41, 39.9]}, properties: {}},
{type: 'Feature', geometry: {type: 'Point', coordinates: [116.39, 39.89]}, properties: {}},
],
};
const pointLayer = new BMap.PointLayer({
icon: 'https://jsapi-demo.bj.bcebos.com/images/markers/marker_blue.png',
iconSize: [22, 33],
scale: 1,
opacity: 1,
isFlat: false, // 图标使用固定像素大小
referCenter: new BMap.Point(116.404, 39.915),
});
pointLayer.setData(data);
map.addLayer(pointLayer);
BMap.PointLayer 支持通过 icon 批量绘制图标点,相比 Marker 更适合大量点数据场景
预览