var pixelProjection = new ol.proj.Projection({
code: 'pixel',
units: 'pixels',
extent: [0, 0, width, height]
});
var layerNC = new ol.layer.Image({
source: new ol.source.ImageStatic({
url: '../cartes/img/' + newMapFileName,
imageSize: [width, height],
projection: pixelProjection,
imageExtent: pixelProjection.getExtent()
})
}),
layerVG = new ol.layer.Image({
source: new ol.source.ImageStatic({
url: '../cartes/img/' + oldMapFileName,
imageSize: [width, height],
projection: pixelProjection,
imageExtent: pixelProjection.getExtent()
})
});
var map = new ol.Map({
layers: [
layerNC,
layerVG
],
target: 'interactiveMap',
controls: [],
view: new ol.View({
projection: pixelProjection,
center: ol.extent.getCenter(pixelProjection.getExtent()),
zoom: 1.75,
maxZoom: 3,
minZoom: 0
})
});
layerVG.on("change", function(){
console.log("loaded");
});
I am trying to make the layer event work and I can't seem to make it fire. Even when I try with moveend
, nothing seems to be working. I want to have an event fire when the image (layer) is loaded for the first time.