简体   繁体   中英

How do I convert Node based OpenLayers project, to using the local ol file?

I have made a web application based around an OpenLayers. I installed OpenLayers through npm, and made everything work.

Due to changes in requirements (yay), i need to remove everything node related, and replace it with local files.

All examples i have been able to find (including on OpenLayers own example page), are doing it the Node way.

So far i have downloaded the dist version of OpenLayers from here: https://openlayers.org/download/

And added that file to my project.

Now i don't get how i'm supposed to replace all my imports, with calls to this file.

This is all the imports i want to replace:

import { Map, View } from "ol";
import TileLayer from "ol/layer/Tile";
import WMTS from "ol/source/WMTS";
import WMTSTileGrid from "ol/tilegrid/WMTS";
import TileWMS from "ol/source/TileWMS";
import { get as getProjection } from "ol/proj";
import Projection from "ol/proj/Projection.js";
import { getTopLeft } from "ol/extent.js";
import { register } from "ol/proj/proj4.js";

When you add this as a normal script tag you will get a global var called ol ..

So all you would need to do is ->

const { Map, View } = ol;
const TileLayer = ol.layer.Tile;
//etc..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM