I would like to use the latest version of OpenLayers (5.3) in small project. The requirements are:
- no Node.js - I will be running thing on the site hosted on IIS, simple HTML files
- scripts need to be written in TypeScript
- ES5
I've read a lot of different discussions and I'm a bit confused. It this even possible? The new OpenLayers has ol
npm package, there are (at least two) types definitions for OpenLayers but I can't get it to work in the browser.
First, it complaining about import
statements which are not recognized. The other issues are that even if I will include full ol.js
I can't get typings to work in TypeScript.
Does anyone have some successful examples?
Fo example bellow the ol
namespace is not recognized:
/// <reference path="ol.js"/>
/// <reference path="../Typings/ol/Map.d.ts"/>
// no imports as they are not working without Node.js
class MainMap {
createMap() {
var map = new ol.Map({
target: 'map',
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
})
],
view: new ol.View({
center: ol.proj.fromLonLat([37.41, 8.82]),
zoom: 4
})
});
}
}
let map = new MainMap();
map.createMap();