如何正确将ol-ext导入网页?

问题描述 投票:0回答:1

我对ol-ext有问题。我想使用ol-ext库中的“ crop”工具,但是包含ol-ext时存在问题我已经使用npm install安装了openlayers和ol-ext。 Openlayers可以正常工作,但是当我尝试将其添加到“ crop”部分时,例如:

var crop = new ol.filter.Crop();

出现问题:

Uncaught ReferenceError: ol is not defined
at Object.parcelRequire.node_modules/ol-ext/dist/ol-ext.js (ol-ext.js:23)
at newRequire (Features.e31bb0bc.js:47)
at localRequire (Features.e31bb0bc.js:53)
at Object.parcelRequire.index.js.ol/ol.css (index.js:11)
at newRequire (Features.e31bb0bc.js:47)
at Features.e31bb0bc.js:81
at Features.e31bb0bc.js:120

我认为可能是导入问题,但是我真的不知道如何正确导入ol-ext。这是我从index.js导入的内容:

import 'ol/ol.css';
import ol from 'ol';
import Map from 'ol/Map';
import View from 'ol/View';
import Draw from 'ol/interaction/Draw';
import {Tile as TileLayer, Vector as VectorLayer} from 'ol/layer';
import {OSM, Vector as VectorSource} from 'ol/source';
import {fromLonLat} from 'ol/proj';
import XYZ from 'ol/source/XYZ';
import {getRenderPixel} from 'ol/render';
import 'ol-ext/dist/ol-ext.js'
javascript openlayers openlayers-3 ol-ext
1个回答
0
投票

您确定作物是过滤器的延伸吗?这是从过滤器导入中导入的“和”

{and} from 'ol/format/filter';

module-ol_format_filter

© www.soinside.com 2019 - 2024. All rights reserved.