简体   繁体   English

(未捕获的 ReferenceError:defaultInteractions 未定义)如何在 Asp.Net Core5 中将“翻译功能”添加到我的 Openlayers6 项目中

[英](Uncaught ReferenceError: defaultInteractions is not defined) How Can I Add "Translate Features" To My Openlayers6 Project In Asp.Net Core5

I'm new to Openlayers.我是 Openlayers 的新手。 While I was using Node.js, my codes were working fine.当我使用 Node.js 时,我的代码运行良好。 But I ran into some problems when I switched to Asp.Net Core.但是当我切换到 Asp.Net Core 时遇到了一些问题。

I learned that when calling modules to use them in Asp.Net Core I need to add some prefixes to their heads.我了解到,在 Asp.Net Core 中调用模块以使用它们时,我需要在它们的头部添加一些前缀。

For example to be able to use the "Map" module:例如能够使用“地图”模块:

const map = new ol.Map({ });

But I don't know what prefix I should add before "defaultInteractions()" in this line但我不知道我应该在这一行的“defaultInteractions()”之前添加什么前缀

interactions: defaultInteractions().extend([select, translate]),

Here is my Map code snippet这是我的地图代码片段

const map = new ol.Map({
    interactions: defaultInteractions().extend([select, translate]),
    layers: [
        new ol.layer.Image({
            source: new ol.source.ImageStatic({
                url: 'https://imgs.xkcd.com/comics/online_communities.png',
                projection: projection,
                imageExtent: extent,
            }),
        }),
        rasterLayer, vectorLayer
    ],
    target: 'map',
    view: new ol.View({
        projection: projection,
        center: ol.extent.getCenter(extent),
        zoom: 2,
        maxZoom: 8,
    }),
});

When I ctrl + left click on defaultInteraction() , the ol.interaction.js page opens,当我 ctrl + 左键单击defaultInteraction()时,会打开ol.interaction.js 页面

When I ctrl + left click on extend([select, translate]) the ol.Collection.js page opens.当我 ctrl + 左键单击extend([select, translate]) ol.Collection.js 页面打开。

But both are not working.但两者都不起作用。

Here is the error i got这是我得到的错误

Thanks in advance and have a good day <(^.^)>提前感谢,祝你有美好的一天<(^.^)>

[已解决]我将行更改为:

interactions: ol.interaction.defaults().extend([select, translate]),

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

相关问题 未捕获的ReferenceError:未在ASP.NET上定义Sys - Uncaught ReferenceError: Sys is not defined on ASP.NET ASP.NET MVC-未捕获的ReferenceError:即使我包括该库,也未定义jQuery - ASP.NET MVC - Uncaught ReferenceError: jQuery is not defined even if I'm including the library Javascript未捕获ReferenceError-ASP.NET MVC - Javascript Uncaught ReferenceError - ASP.NET MVC 如何在 Openlayers6 中绘制 lineString - How to draw a lineString in Openlayers6 我如何修复错误 Uncaught ReferenceError: addEvent is not defined - How can i fix the error Uncaught ReferenceError: addEvent is not defined 如何将自定义样式表和脚本添加到ASP.NET Core项目? - How do I add custom stylesheets and scripts to a ASP.NET Core project? 如何解决“未捕获的ReferenceError:未定义blob”? - How can I solve “Uncaught ReferenceError: blob is not defined”? 如何修复 Uncaught (in promise) ReferenceError: require is not defined with Vite? - How can I fix Uncaught (in promise) ReferenceError: require is not defined with Vite? 未捕获的ReferenceError:我没有定义 - Uncaught ReferenceError: i is not defined 参考错误:PDFJS 未定义 Asp.net - ReferenceError: PDFJS is not defined Asp.net
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM