Geographic Information Systems Asked by Riverendell on August 13, 2021
This is the code that OpenLayers provides for a quick startup point:
import Map from 'ol/Map';
import View from 'ol/View';
import OSM from 'ol/source/OSM';
import TileLayer from 'ol/layer/Tile';
new Map({
layers: [
new TileLayer({source: new OSM()})
],
view: new View({
center: [0, 0],
zoom: 2
}),
target: 'map'
});
However, since I’m importing using a CDN, instead of importing specific modules I specify the full path instead, for example ol.source.OSM()
instead of OSM from 'ol/source/OSM'
. This works for each component except TileLayer, which returns the error "ol.layer.Tile.TileLayer is not a constructor". I know I can just use ol.layer.Tile
but TileLayer seems to have better panning bounds. I’ve checked for version problems and I’m using the latest version of ol, what could be the problem?
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP