1

Another problem I have........I know how to preload images using jquery, but how can preloading be done with static images?

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

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

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

The static image layer stays the same and the source (url) is changing on mouseover.

The preloading part is especially needed when I have 2 or more image layers and I need to show the image layers in one go (and prevent img-layer1 showing where img-layer2 is still loading and comes up a few seconds later).

user1939338
  • 117
  • 9
  • 1
    Loading into an image object should be enough to cache the url in your browser. If that doesn't do it you could save the images to data urls and use those in OpenLayers. – Mike Jan 18 '19 at 12:54
  • Thx again.......loading into an image object with width/height of 0px did the trick!! – user1939338 Jan 18 '19 at 13:30

0 Answers0