1

I want to use a folder with cached bing map tiles for using it with openlayers 2. After a google search, i haven't find any example on how to use the tiles locally. The tiles are saved as ".png" in my folder. For example the following image is saved as 1221002.png


enter image description here


The only example that i have found is this link from openlayers site https://wiki.openstreetmap.org/wiki/OpenLayers_Local_Tiles_Example

with the following piece of code

// This is the layer that uses the locally stored tiles var newLayer = new OpenLayers.Layer.OSM( "Local Tiles", "tiles/${z}/${x}/${y}.png", {numZoomLevels: 19, alpha: true, isBaseLayer: false} );

What i have tried so far is to set my code as follows

var newLayer = new OpenLayers.Layer.OSM(
         "Local Tiles", 
         "tiles/${z}${x}${y}.png",           <--- Slashes removed
         {numZoomLevels: 19, 
          alpha: true, 
          isBaseLayer: false}
     );

but with no luck. Is this the correct approach?

  • don't remove the slashes and your path should be something like ('FolderPath/FolderName/{z}/{x}/{y}.png'). – Moh Mar 25 '18 at 11:11
  • The Bing Maps terms of use do not allow storing the map tiles offline (Ie caching). – rbrundritt Mar 25 '18 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.