[OSM-dev] Show Image of Data not Available where Tiles are Empty

Peter Körner osm-lists at mazdermind.de
Fri Jul 9 00:38:44 BST 2010


Am 09.07.2010 00:07, schrieb PARVEEN ARORA:
> Dear List,
Hi!

>   I am trying to show a default image of data not available or data
> coming soon
> where tiles are empty or not available with the help of following script:
>
> http://www.openstreetmap.org/openlayers/OpenStreetMap.js
>
> I have added this script to my index.html page
> but this script is not working or i do not know how it can work
> correctly.
You can take a look at [1] where this script is used.

> Is there any other way to show the default image in empty tiles ?
> Please Help..

It seems this is done by the code snippet around 
OpenLayers.Util.onImageLoadError. There is a if-switch that uses 
this.src. to limit the error-image to tiles loaded from 
*.openstreetmap.org. You could override this behaviour by putting a 
<script />-Tag after the <script />-Tag that loads OpenStreetMap.js like 
this:

<script type="text/javascript">
OpenLayers.Util.onImageLoadError = function() {
   this.src = "/url/to/your/error.png
};
</script>


Peter

[1] <http://toolserver.org/~osm/styles/>




More information about the dev mailing list