Reproject static image: updating source transforms the image again












0















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.










share|improve this question





























    0















    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.










    share|improve this question



























      0












      0








      0








      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.










      share|improve this question
















      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.







      openlayers openlayers-5






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited yesterday







      user1939338

















      asked yesterday









      user1939338user1939338

      437




      437
























          1 Answer
          1






          active

          oldest

          votes


















          1














          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")
          });





          share|improve this answer
























          • So simple ;-)........thx again for helping Mike!!

            – user1939338
            yesterday











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54251511%2freproject-static-image-updating-source-transforms-the-image-again%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          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")
          });





          share|improve this answer
























          • So simple ;-)........thx again for helping Mike!!

            – user1939338
            yesterday
















          1














          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")
          });





          share|improve this answer
























          • So simple ;-)........thx again for helping Mike!!

            – user1939338
            yesterday














          1












          1








          1







          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")
          });





          share|improve this answer













          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")
          });






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered yesterday









          MikeMike

          1,455127




          1,455127













          • So simple ;-)........thx again for helping Mike!!

            – user1939338
            yesterday



















          • So simple ;-)........thx again for helping Mike!!

            – user1939338
            yesterday

















          So simple ;-)........thx again for helping Mike!!

          – user1939338
          yesterday





          So simple ;-)........thx again for helping Mike!!

          – user1939338
          yesterday


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54251511%2freproject-static-image-updating-source-transforms-the-image-again%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Callistus III

          Plistias Cous

          Index Sanctorum