简体   繁体   中英

(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. 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 <(^.^)>

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM