无论屏幕尺寸如何,我都希望我的地图从左上角开始。每次我使用extent
设置它我调整大小并重新加载,我不再是左上角了。我希望当我调整大小时它会改变,但我需要它在页面加载时从左上角的地图开始。
var extent = [0, 0, 1685, 895];
var projection = new ol.proj.Projection({
units: 'pixels',
extent: [0, 0, 1685, 895]
});
var map = new ol.Map({
layers: [
new ol.layer.Image({
source: new ol.source.ImageStatic({
url: 'assets/img/map.png',
projection: projection,
imageExtent: [0, 0, 1685, 895]
})
})
],
target: 'map',
view: new ol.View({
projection: projection,
center: ol.extent.getCenter(extent),
zoom: 3,
maxZoom: 8
})
});