I'm testing OpenLayers 6 beta. ol.inherits looks missing in OpenLayers 6.
ol.inherits(ol.source.NowMap, ol.source.OSM);
This causes error
Uncaught TypeError: ol.inherits is not a function
What should I use instead?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.
Sign up to join this communityIt's mentioned in the update notes https://github.com/openlayers/openlayers/blob/master/changelog/upgrade-notes.md
A simple fix which the ol-ext library uses is to replace it with the something based on the old function
var ol_ext_inherits = function(child,parent) {
child.prototype = Object.create(parent.prototype);
child.prototype.constructor = child;
};
or see the OL6 examples for a method which will need some recoding https://openlayers.org/en/master/examples/custom-controls.html https://openlayers.org/en/master/examples/custom-interactions.html
Just a notice, as I do not have the reputation points requred for a proper comment. The suggested solutions is actually more in line with recomendations than the code given in the actual OpenLayers examples that are linked. Namely, the __proto__
method is deprecated and the proper method for inheritance is by using Object.create()
. Link.
Cheers,
Miha