Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

openlayers import Map vs array Map

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

like image 579
Peter Belbin Avatar asked Oct 16 '25 13:10

Peter Belbin


1 Answers

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.

like image 123
casieber Avatar answered Oct 18 '25 10:10

casieber



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!