从mapbox更改过滤标记群集组示例

时间:2018-02-08 08:35:19

标签: javascript mapbox mapbox-marker

我想从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
    ]
  }
}

1 个答案:

答案 0 :(得分:0)

您可以使用geojson直接致电featureLayer

L.mapbox.featureLayer(geojson)
    .on('ready', function(e) {
        ...
    });