Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am creating a map in OpenLayers using Base layer as ESRI online map server. And second layer as our own esri map server serving the overlay. The Base layer shows correctly, but OpenLayer requests some extra tiles at lower zoom levels which donot exist. Check this image too see what i mean:

enter image description here

Now if i zoom in everything looks fine and the data in the overlay is correct. But how do i make openlayers not request those pink tiles??

Here is the related code:

For Base Map:

 // layerURL loaded using OpenLayers.Protocol.Script()
var baseLayer = new OpenLayers.Layer.ArcGISCache("Street Map", layerURL, {
    layerInfo : layerInfo,
    type : 'png'
    });

    map = new OpenLayers.Map('map', {
    maxExtent : baseLayer.maxExtent,
    units : baseLayer.units,
    resolutions : baseLayer.resolutions,
    numZoomLevels : baseLayer.numZoomLevels,
    tileSize : baseLayer.tileSize,
    displayProjection : baseLayer.displayProjection
    });


    //The layer with the bad tile problem
    layer = new OpenLayers.Layer.XYZ("ESRI", "http://url_removed/tile/${z}/${y}/${x}", {
    format : "image/jpg",
    transparent : "true",
    isBaseLayer : false,
    opacity : 0.8
    });
share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

use this:

OpenLayers.Util.onImageLoadError = function() {this.src = '/img/noimg.png';};

i hope it helps you...

share|improve this answer
    
Thanks buddy! Yep that worked! I still wonder why the wrong tiles are getting generated and if there is a way to fix that. –  Shaunak Jun 18 '12 at 15:28
    
try to change format : "image/jpg" to png... –  Aragon Jun 18 '12 at 15:33
    
tried. It still requests those tiles. –  Shaunak Jun 18 '12 at 16:28
    
Try to use arcgisrest for openlayers and define your extents in arcgis server on your service. –  Aragon Jun 18 '12 at 17:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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