【发布时间】:2023-02-05 19:00:02
【问题描述】:
我正在尝试将 open layers v7.2.2 与 typescript 一起使用。 {没有打字稿,代码按预期工作}
function OnMapClick(Event : MapBrowserEvent<UIEvent>)
{
Event.map.forEachFeatureAtPixel(Event.pixel, function(CurrentFeature : Feature)
{
...
}
}
错误 : 类型错误:“(CurrentFeature: Feature) => void”类型的参数不可分配给“(arg0: FeatureLike, arg1: Layer<Source, LayerRenderer>, arg2: SimpleGeometry) => void”类型的参数。 参数类型“CurrentFeature”和“arg0”不兼容。 类型“FeatureLike”不可分配给类型“Feature”。 类型“RenderFeature”缺少类型“Feature”中的以下属性:on、once、un、geometryName_ 等 40 个。
任何帮助将非常感激。 :-)
【问题讨论】:
-
该方法可以处理来自矢量图层的
Feature和来自矢量切片层的RenderFeature。FeatureLike是正确的声明。
标签: javascript typescript openlayers