0
我跟在openlayers手册的example上,在osf层顶部添加静态图像。它可以工作,但我的图像(256x256)显示为矩形。我试图与周围的投影坐标,并检查了这里的其他职位,但为什么图像不显示为一个正方形,我不能让我的头周围:图像在osf层顶部的静态图像层上显示错误
// Create map
var map = new ol.Map({
target: 'map', // The DOM element that will contains the map
renderer: 'canvas', // Force the renderer to be used
layers: [
// Add a new Tile layer getting tiles from OpenStreetMap source
new ol.layer.Tile({
source: new ol.source.OSM()
})
],
// Create a view centered on the specified location and zoom level
view: new ol.View({
center: ol.proj.transform([16.3725, 48.208889], 'EPSG:4326', 'EPSG:3857'),
zoom: 4
})
});
// Create an image layer
var imageLayer = new ol.layer.Image({
opacity: 0.75,
source: new ol.source.ImageStatic({
attributions: [
new ol.Attribution({
html: ''
})
],
url: 'https://placebear.com/256/256',
imageSize: [256, 256],
projection: map.getView().getProjection(),
imageExtent: ol.extent.applyTransform(
[0, 0, 16.3725, 48.208889], ol.proj.getTransform("EPSG:4326", "EPSG:3857"))
})
});
map.addLayer(imageLayer);
感谢您的澄清,实际上我想显示一个覆盖图像,例如顶部的战略地图。关于图像投影,我很困惑如何计算像素的纬度/经度坐标。有没有一种方法可以从起点计算经纬度,简单地说,在南方走x米(如果我说像素是一米)? –
我现在添加它作为预期的事情。所以我的问题现在已经过时了。 –