Reputation: 115
I'm getting this error **Uncaught TypeError: Cannot read property 'sources' of undefined**
(mapbox-gl.js:4) when trying to load a tile as a mapbox-gl
source.
<div id='map' style='height:500px;width:700px;'>
</div>
<script>
var accessToken='<my access token>'
mapboxgl.accessToken = accessToken;
var map = new mapboxgl.Map({
container: 'map',
style: 'https://www.mapbox.com/mapbox-gl-styles/styles/outdoors-v4.json', //stylesheet location
center: [-34.6, -58.4],
zoom: 11
});
var sourceObj = new mapboxgl.Source({
type: 'vector',
url: 'mapbox://<some map id>'
});
map.addSource('test',sourceObj);
</script>
If I don't load any source, everything works well. This happens with the 0.2.1
and 0.2.2
versions of the API. I tried with different tiles and I get the same problem.
Any clue?
Thanks in advance
Upvotes: 1
Views: 2631