I have some data hosted on mapbox and I'm trying to load it as tiled geojson into Leaflet from its mapbox id (I just want to get plain geojson, I'm not trying to render it). How can I achieved that?
I tried this snippet:
L.mapbox.accessToken = 'myAccessToken';
var featureLayer = L.mapbox.featureLayer('myDataId');
but it doesn't work, I get the following error:
" could not load features at http://a.tiles.mapbox.com/v4/"myDataId"/features.json?access_token="myAccessToken" "
Answer
I also haven't been able to get L.mapbox.featureLayer()
to load vectors I've uploaded to MapBox. Vector Tile source .mbtiles
files are no longer .geojsons
but have been converted into a bunch of tiled .svgs
combined into one .mbtiles
file, so I'm not sure if mapbox.js has the ability to render vector .mbtiles
the same was it renders hosted .geojson
files.
If you want to render the vector tileset on your map, try styling it in Mapbox Studio and uploading the style project to MapBox (docs).
EDIT
OK, so looks like there are two different ways to import vector data into mapbox:
- as a
.geojson
within the MapBox Editor.
- as a vector
.mbtiles
set, uploaded via MapBox Studio or from the MapBox Uploads page.
Data uploaded via the first method can be loaded onto a map with L.mapbox.featureLayer
. Data uploaded via the second method (tiled) must be first given a style in MapBox Studio (see link above) or rendered in a mapbox-gl map.
In summary: it is not possible to access the geojson data of a vector tiles source.
No comments:
Post a Comment