[英]Load open layers map to electron js with typescript imports
I'm trying to load openlayers map in electron using typescript imports. 我正在尝试使用打字稿导入在电子中加载openlayers映射。 But when compiling following exception pops up 但是在编译时会弹出以下异常
This is the code I am trying to run 这是我试图运行的代码
import Map from 'ol/Map'; import View from 'ol/View'; import TileLayer from 'ol/layer/Tile'; import XYZ from 'ol/source/XYZ'; new Map({ target: 'map', layers: [ new TileLayer({ source: new XYZ({ url: 'https://{ac}.tile.openstreetmap.org/{z}/{x}/{y}.png' }) }) ], view: new View({ center: [0, 0], zoom: 2 }) });
Is there a way to load latest open layers with electron? 有没有办法用电子加载最新的开放层?
Thanks in advance 提前致谢
Why not just go with an OSM source? 为什么不只使用OSM源呢?
import Map from 'ol/Map.js';
import View from 'ol/View.js';
import TileLayer from 'ol/layer/Tile.js';
import OSM from 'ol/source/OSM.js';
var map = new Map({
layers: [
new TileLayer({
source: new OSM()
})
],
target: 'map',
view: new View({
center: [0, 0],
zoom: 2
})
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.