[英](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.