简体   繁体   English

如何在 Openlayers 中的 DragAndDrop 上使用 GeoJson 作为 Formatconstructor

[英]How to use GeoJson as a Formatconstructor on DragAndDrop in Openlayers

I followed this example from openlayers: https://openlayers.org/en/latest/examples/drag-and-drop.html我从openlayers遵循了这个例子: https://openlayers.org/en/latest/examples/drag-and-drop.html

But my project is built on typescript and the Geojson format gives the following error:但是我的项目是建立在 typescript 之上的,并且 Geojson 格式给出了以下错误:

Type 'typeof GeoJSON' is missing the following properties from type 'FeatureFormat': dataProjection, defaultFeatureProjection, adaptOptions, getReadOptions, and 8 more. “typeof GeoJSON”类型缺少“FeatureFormat”类型的以下属性:dataProjection、defaultFeatureProjection、adaptOptions、getReadOptions 等 8 个。

This is the code I use and the error appears on the Geojson in the formatconstructors.这是我使用的代码,错误出现在格式构造器中的 Geojson 上。

import { defaults, DragAndDrop } from 'ol/interaction';
import {GeoJSON} from 'ol/format';


this.dragAndDropInteraction = new DragAndDrop({
    formatConstructors: [GeoJSON]
})

The solution was to overrule the typescript checking as following解决方案是否决 typescript 检查如下

this.dragAndDropInteraction = new DragAndDrop({
    formatConstructors: [GeoJSON as any]
})

Source: https://github.com/Microsoft/TypeScript/issues/9448来源: https://github.com/Microsoft/TypeScript/issues/9448

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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