1

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

1 Answer 1

1

This is a bug in Mapbox GL which we will fix. Thanks for the report.

Sign up to request clarification or add additional context in comments.

1 Comment

Is this still a bug? i'm having trouble running the addsource() provided snippet from MapBox's [documentation page] (mapbox.com/mapbox-gl-js/api/#VideoSource)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.