0

I have a BBOX area of my county. I serving the OSM tiles (Apache 2) from a local disk using openlayers 2 XYZ scheme. How can I prevent loading non-existent files out of my BBOX area? I have 8 zoom levels with around 400k tiles.

I managed to "disable" the visibility of non-existent and pink tiles with a CSS trick but I can't prevent the browser reading these files.

I always got these errors in browsers console (there are hundreds of them):

Failed to load resource: the server responded with a status of 404 (Not Found)

OL2:

new OpenLayers.Layer.XYZ("OSM Offline",
  ["http://localhost/csongradm/${z}/${x}/${y}.png"],
    {
      numZoomLevels: 18,
      visibility: true,
      sphericalMercator: true,
      isBaseLayer: true,
      buffer: 3
    })
1

Use restrict extent as below example, so User will not go beyond the defined extent.
Reference: http://dev.openlayers.org/docs/files/OpenLayers/Map-js.html#OpenLayers.Map.restrictedExtent

Example:
http://dev.openlayers.org/examples/restricted-extent.html

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.