Mapbox-gl-js: TypeError: Cannot use 'in' operator to search for 'ref' in <geojson>

Created on 22 Aug 2016  Â·  1Comment  Â·  Source: mapbox/mapbox-gl-js

mapbox-gl-js version: 0.22.1
JS Bin: http://jsbin.com/heguxesiwu/4/edit?html,output

Steps to Trigger Behavior

  1. Visit the bin
  2. Observe frozen map as a result of a type eror

n.b. Discovered while attempting to replicate this example.

Expected Behavior

The following block should create some outlines (NYC boroughs).

        map.on('load', function() {
            map.addSource("boroughs", {
                "type": "geojson",
                "data": "https://raw.githubusercontent.com/dwillis/nyc-maps/master/boroughs.geojson"
            });

            map.addLayer("borough-fills", {
                "id": "borough-fills",
                "type": "fill",
                "source": "boroughs",
                "layout": {},
                "paint": {
                    "fill-color": "#627BC1",
                    "fill-opacity": 0.5
                }
            });

        });

Actual Behavior

The geojson fails to load, is not parsed to JSON, or breaks some other way and the map freezes/breaks.

Console output

TypeError: Cannot use 'in' operator to search for 'ref' in borough-borders(…)fire @ evented.js:92_render @ map.js:1059

Most helpful comment

Human Error: Bad call to map.addLayer

Correct call

            map.addLayer({
                "id": "borough-fills",
                "type": "fill",
                "source": "boroughs",
                "layout": {},
                "paint": {
                    "fill-color": "#627BC1",
                    "fill-opacity": 0.5
                }
            });

>All comments

Human Error: Bad call to map.addLayer

Correct call

            map.addLayer({
                "id": "borough-fills",
                "type": "fill",
                "source": "boroughs",
                "layout": {},
                "paint": {
                    "fill-color": "#627BC1",
                    "fill-opacity": 0.5
                }
            });

Was this page helpful?
0 / 5 - 0 ratings