0

我想从 mapbox.js https://www.mapbox.com/mapbox.js/example/v1.0.0/filtering-marker-clusters/更改示例。现在我的问题是我想使用本地 geojson 变量而不是

    .loadURL('/mapbox.js/assets/data/stations.geojson') 

喜欢

var geojson = {
"features": [
{
  "type": "Feature",
  "properties": {
    "name": "Van Dorn Street",
    "marker-color": "#0000ff",
    "marker-symbol": "rail-metro",
    "line": "blue"
  },
  "geometry": {
    "type": "Point",
    "coordinates": [
      -77.12911152370515,
      38.79930767201779
    ]
  }
},
{
  "type": "Feature",
  "properties": {
    "name": "Franconia-Springfield",
    "marker-color": "#0000ff",
    "marker-symbol": "rail-metro",
    "line": "blue"
  },
  "geometry": {
    "type": "Point",
    "coordinates": [
      -77.16797018042666,
      38.766521892689916
    ]
  }
}

]

4

1 回答 1

0

您可以使用 geojson 直接调用featureLayer

L.mapbox.featureLayer(geojson)
    .on('ready', function(e) {
        ...
    });
于 2018-02-12T10:20:17.530 回答