我有一些 png(透明雷达图像),我想显示为图像层。这样做没问题........我加载了一个图像,而不是删除它,加载一个新的,删除它等等......但是通过这样做,过渡并不平滑(更多像闪烁的图像)就像我希望的那样。我怎样才能使这些顺利?
var center = ol.proj.transform([5.2, 52.443], 'EPSG:4326', 'EPSG:3857');
var map = new ol.Map({
target: 'map',
controls: ol.control.defaults({
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
collapsible: true
})
}),
layers: [
new ol.layer.Tile({
source: new ol.source.OSM({
url: 'http://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png'
})
})
],
view: new ol.View({
center: center,
zoom: 6
})
});
var url = url of transparent radarimage (http://......)
var imageBounds = [0.813 , 50.520 , 10.996, 54.295 ];
var imageLayer = new ol.layer.Image({
opacity: opacity,
source: new ol.source.ImageStatic({
url: url,
imageSize: [1315, 799],
projection: map.getView().getProjection(),
imageExtent: ol.extent.applyTransform(imageBounds, ol.proj.getTransform("EPSG:4326", "EPSG:3857"))
})
});
map.addLayer(imageLayer); // to add imageLayer to the map.
map.removeLayer(imageLayer); // to remove imageLayer from the map.
编辑 2:按照建议(谢谢!)尝试使用以下方法更新源:
s = new ol.source.Image({
source: new ol.source.ImageStatic({
url: url
})
});
l=map.getLayers().getArray()[1]; // 1 = Radar layer
l.setSource(s);
图层没有被刷新.......