簡體   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

我是 Openlayers 的新手。 當我使用 Node.js 時,我的代碼運行良好。 但是當我切換到 Asp.Net Core 時遇到了一些問題。

我了解到,在 Asp.Net Core 中調用模塊以使用它們時,我需要在它們的頭部添加一些前綴。

例如能夠使用“地圖”模塊:

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

但我不知道我應該在這一行的“defaultInteractions()”之前添加什么前綴

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

這是我的地圖代碼片段

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 頁面

當我 ctrl + 左鍵單擊extend([select, translate]) ol.Collection.js 頁面打開。

但兩者都不起作用。

這是我得到的錯誤

提前感謝,祝你有美好的一天<(^.^)>

[已解決]我將行更改為:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM