我想从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
]
}
}
答案 0 :(得分:0)
您可以使用geojson直接致电featureLayer:
L.mapbox.featureLayer(geojson)
.on('ready', function(e) {
...
});