How to enable typescript plug-in openlayers 3?
I want to try creating a simple map in openlayers using typescript:
https://github.com/borisyankov/DefinitelyTyped/blob/master/openlayers/openlayers.d.ts
I take this file, put it in
/typings/openlayers/openlayers.d.ts
I have an app.ts file at the top of my root directory which I put:
import {map} from "olx";
In my tsconfig.json, I have included the path to the openlayers.d.ts file. But I am getting olx not detected when I use the tsc command from the npm typescript package.
All I'm going to do is draw a simple openlayers3 map, hoping that if possible it will not deviate from javascript.
Install openlayers first:
npm install openlayers
Then set the openlayers types to your dev env:
npm install --save-dev @types/openlayers
To import, I tried:
import * as ol from 'openlayers';
Then you can call anything in openlayers like this:
new ol.Map();
import {Map} from "olx";
This won't work as there is no external external module named "olx"
. also olx
links to something else on NPM https://www.npmjs.com/package/olx so we don't recommend using that name.
Recommend https://www.npmjs.com/package/openlayers
With a definition file expanded as:
declare module "openlayers" {
export = olx;
}