0

I have a strange behavior here using OpenLayers 5.2.0, Cesium, and the compatibility library ol-cesium. When I try to add a layer to the map, it throws an exception:

TypeError: invalid 'instanceof' operand type[En savoir plus] asserts.js:6
    assertInstanceof asserts.js:6
    createSingleLayerCounterparts VectorSynchronizer.js:106:4
    _loop AbstractSynchronizer.js:127:24
    addLayers_ AbstractSynchronizer.js:100:28
    listenForGroupChanges_/listenAddRemove</contentKeys< AbstractSynchronizer.js:253:12
    h events.js:41:11
    i</e.prototype.dispatchEvent Target.js:95:12
    M</t.prototype.insertAt Collection.js:178:4
    M</t.prototype.push Collection.js:203:4
    Rs</t.prototype.addLayer PluggableMap.js:498:11
    draw_graphMap http://127.0.0.1:8000/static/carto/js/map_graph.js:166:5
    success http://127.0.0.1:8000/static/graph/js/completion.js:135:17
    u http://127.0.0.1:8000/static/js/jquery-3.3.1.min.js:2:27452
    fireWith http://127.0.0.1:8000/static/js/jquery-3.3.1.min.js:2:28202
    k http://127.0.0.1:8000/static/js/jquery-3.3.1.min.js:2:77649
    n/< http://127.0.0.1:8000/static/js/jquery-3.3.1.min.js:2:79907

And the weirder thing is that it happens also when I try to add an empty layer to the map.

var GraphGeoSource = new ol.source.Vector({});

var GraphLayer = new ol.layer.Vector({
    source: GraphGeoSource
});

map.addLayer(GraphLayer);

I noticed that it happened only when I try to add a vector layer to the map. WMS tiles for instance don't cause any problems and displays fine in Cesium's 3D view.

  • 1
    It has to been something elsewhere in your code, there's nothing wrong with the code you have included in normal OpenLayers. I've used empty vector layers in 5.2.0 in conjunction with a layer switcher control and set the "change:visible" event to turn on/off features such as a graticule. Google search reveals VectorSynchronizer.js is a Cesium component, presumably you are using that so I suggest you tag your question Cesium. – Mike Oct 23 '18 at 14:40
  • I can confirm Mike statement. The issue is elsewhere in your code. You can see a small demo using OpenLayers 5.2.0, ol.layer.Vector and ol.source.Vector at codepen.io/anon/pen/gBBXoL to demonstrate the point (it's working) – ThomasG77 Oct 23 '18 at 23:26
  • Thanks for your answer, you were right, the problem actually comes from the ol-cesium library linking Openlayers and Cesium. I'll edit my post accordingly. – BFlat Oct 24 '18 at 8:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.