与以前版本中指定的方式相同collapsible: false
(请注意,OSM 和其他一些来源的使用条款要求始终在其瓷砖用于面向公众的网站上时始终可见属性)
import Map from 'ol/Map.js';
import View from 'ol/View.js';
import {defaults as defaultControls} from 'ol/control.js';
import TileLayer from 'ol/layer/Tile.js';
import OSM from 'ol/source/OSM.js';
var map = new Map({
layers: [
new TileLayer({
source: new OSM()
})
],
controls: defaultControls({ attributionOptions: { collapsible: true } }),
target: 'map',
view: new View({
center: [0, 0],
zoom: 2
})
});
或者如果您使用的是完整版本:
var map = new ol.Map({
target: 'map',
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
})
],
controls: ol.control.defaults({ attributionOptions: { collapsible: true } }),
target: 'map',
view: new ol.View({
center: [0, 0],
zoom: 2
})
});