0
votes

Got stuck.......I'm loading png images onto OpenStreetMap as a static image layer. When I reproject the map from e.g. 3857 to 32661 the image is also reprojected automatically (which I wanted), but when I update the source of the static image the image layer is transformed again. The transformed image has again a rectangle shape like the original one......frustrating....

How can I get the image to not transform again, but just show the updated source (that has the same dimensions as the original one, but transformed according to the new projection).

I have an imagelayer "IMG_LYR" with source "IMG_LYRStaticSource":

IMG_LYRbounds = [45.3, 30.9, -14.6, 72.6]; // LON/LAT
url = "http://localhost/img/myupdatedimg.png";

IMG_LYR = new ol.layer.Image({
    source: IMG_LYRStaticSource
});

IMG_LYRStaticSource = new ol.source.ImageStatic({
    url: url,
    projection: map.getView().getProjection().getCode(),
    imageExtent: ol.extent.applyTransform(IMG_LYRbounds, ol.proj.getTransform("EPSG:4326", map.getView().getProjection().getCode()))
});

When I show the 'projection' in the inspect-console it's confirmed that it is "32661". What am I doing wrong??

Btw: I use also Proj4 defs! That that works is confirmed when the original image and the underlying map transforms when the new projection 32661 is set.

1

1 Answers

1
votes

Only your view projection is changing, the projection of the static image doesn't change, just like OSM it will be reprojected by the view.

IMG_LYRStaticSource = new ol.source.ImageStatic({
    url: url,
    projection: "EPSG:3857",
    imageExtent: ol.extent.applyTransform(IMG_LYRbounds, ol.proj.getTransform("EPSG:4326", "EPSG:3857")
});