I've created a map using openlayers contains osm, google layers and some vector features, On loading it shows two errors like: GET http://tile.openstreetmap.org/0/0/1.png 404 (Not Found). How to prevent this , I've googled it, and i can't understand what is the exact problem and how to solve this please help me.
3 Answers
You are asking for the second tile (in the y direction) in zoom level 0. It only has one tile at that level (at http://tile.openstreetmap.org/0/0/0.png).
Something is wrong with your code, or the js you are importing.
you cant prevent this. it says that the server you have used for openstreetmap dont have image at this url.
but you can use this code for image loading error:
OpenLayers.Util.onImageLoadError = function(){
this.src='http://www.openlayers.org/api/img/blank.gif';
};
i hope it helps you...
-
Shows a new error Failed to load resource: the server responded with a status of 404 (Not Found).– biosCommented Aug 14, 2012 at 11:02
-
-
I've not used paths to create map only added two scripts: <script src="maps.google.com/maps/api/…> <script src="openlayers.org/api/OpenLayers.js"></script>– biosCommented Aug 14, 2012 at 11:20
-
1@Aragon, onImageLoadError has been deprecated, see my answer below. Commented Aug 14, 2012 at 15:20
OpenLayers.Util.onImageLoadError no longer exists
To replace a tile that couldn't be loaded with a static image, create a css selector for the .olImageLoadError
class (e.g. a background-image
):
.olImageLoadError {
background: url(./images/missing-tile.png) no-repeat scroll 0 0 transparent !important;
opacity: 1.0 !important;
}
For more complex tile loading error handling, register a listener to the layer's tileerror
event.
Corresponding issues/pull requests:
onImageLoadError
was removed by this commit.