代码
const map = new BMap.Map('map');
map.centerAndZoom(new BMap.Point(116.404, 39.924), 15);

// 包含了点、线、面数据的geojson
var geojson = {
  type: 'FeatureCollection',
  features: [
    {
      type: 'Feature',
      geometry: {type: 'Point', coordinates: [116.404, 39.915]},
      properties: {name: '天安门'},
    },
    {
      type: 'Feature',
      geometry: {
        type: 'LineString',
        coordinates: [
          [116.39, 39.91],
          [116.41, 39.91],
          [116.42, 39.92],
        ],
      },
      properties: {name: '示例线'},
    },
    {
      type: 'Feature',
      geometry: {
        type: 'Polygon',
        coordinates: [
          [
            [116.395, 39.925],
            [116.415, 39.925],
            [116.415, 39.935],
            [116.395, 39.935],
            [116.395, 39.925],
          ],
        ],
      },
      properties: {name: '示例面'},
    },
  ],
};

var layer = new BMap.GeoJSONLayer('demo-layer', {
  dataSource: geojson,
  markerStyle: {fillColor: '#1890ff'},
  polylineStyle: {strokeColor: '#ff4d4f', strokeWeight: 3},
  polygonStyle: {
    fillColor: '#52c41a',
    fillOpacity: 0.4,
    strokeColor: '#389e0d',
    strokeWeight: 2,
  },
});

map.addLayer(layer);

GeoJSONLayer 可以叠加各种类型的geojson数据

预览