(未定义的参考文献:未定义默认交互式)如何添加“翻译功能”。在ASP.NET CORE5中的我的OpenLayers6项目中

发布于 2025-02-07 21:46:05 字数 1376 浏览 4 评论 0原文

我是开放层的新手。当我使用node.js时,我的代码工作正常。但是,当我切换到ASP.NET核心时,我遇到了一些问题。

我了解到,当调用模块在ASP.NET Core中使用它们时,我需要在其头部添加一些前缀。

例如,能够使用“映射”模块:

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

但是我不知道我应该在“ defaultInteractions()” 之前添加哪个前缀,这

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

是我的 map 代码段

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,
    }),
});

时,当我ctrl +左键单击 defaultInteraction() ol.interaction.js page 打开时,

当我ctrl + ctrl +左键单击 extend([[[[[选择,翻译]) ol.collection.js页面打开。

但是两者都没有起作用。

这是我得到的错误

祝您有美好的一天<(^。^)>

I'm new to Openlayers. While I was using Node.js, my codes were working fine. But I ran into some problems when I switched to 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.

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

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,

When I ctrl + left click on extend([select, translate]) the ol.Collection.js page opens.

But both are not working.

Here is the error i got

Thanks in advance and have a good day <(^.^)>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

最偏执的依靠 2025-02-14 21:46:05

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

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

[solved]
I changed the line to:

interactions: ol.interaction.defaults().extend([select, translate]),
一萌ing 2025-02-14 21:46:05

注意:

使用ol.Interaction.defaults.defaults()。Extent()

var map = new ol.Map({
    interactions: ol.interaction.defaults.defaults().extend([select, translate]),
    // interactions: ol.interaction.defaults().extend([select, translate]), // wrong

...
})

Notice:

Using ol.interaction.defaults.defaults().extend()

var map = new ol.Map({
    interactions: ol.interaction.defaults.defaults().extend([select, translate]),
    // interactions: ol.interaction.defaults().extend([select, translate]), // wrong

...
})
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文