Openlayers Map vs javascript's built-in Map object.
at https://github.com/openlayers/openlayers/tree/master/package
the suggestion is that a new openlayers map can be created by using new Map({ // properties });
but how does one then also use the javascript built-in Map documented here:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
?
if I want to use both in the same javascript, how is that done (ie: to differentiate them?)
thank you! peter
Looking at the OpenLayer's example code provided in the page you linked, they suggested doing the following:
import Map from 'ol/map';
Because the Map
you are importing is a default export from the ol/map
path, you can name it whatever you like in order to avoid any naming conflicts. For example, you could instead write.
import OLMap from 'ol/map';
and then use new OLMap({...})
for the OpenLayers map while still being able to use Map
for the built-in type.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With