[OpenLayers-Users] change tms layer does not change map view

Juan Abreu juanabreu at hotmail.com
Sat Aug 31 01:48:27 PDT 2013


I have a TMS layer that I'm using as my map, i have set it up so that 
users can change the map
however changing the layer does not update the map view until i hit the 
zoom in button or the zoom out button. how can i refresh the map view to
 show the newly added layer?
here is a quick code sample. i tried layer.redraw() without any 
solution. does someone have any other ideas.on a desperate  i just try setting the map div html to "" and it 
finally updated the layer. is this the proper way to do this?

[code sample below]
function initMAP() {
    var mapBounds = new OpenLayers.Bounds(bounds[0], bounds[1], bounds[2], bounds[3]);
    var mapMinZoom = 0;
    var mapMaxZoom = 3;

    // avoid pink tiles
    OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;
    OpenLayers.Util.onImageLoadErrorColor = "transparent";




    var options = {
        theme: null,
        controls: [

        new OpenLayers.Control.Navigation({
            dragPanOptions: {
                //     enableKinetic: true
            }
        }),
        new OpenLayers.Control.Attribution(),
        new OpenLayers.Control.Zoom()
        ],

        maxExtent: new OpenLayers.Bounds(bounds[0], bounds[1], bounds[2], bounds[3]),
        maxResolution: 4,
        numZoomLevels: 3

    };


    map = new OpenLayers.Map('map', options);

      layer = new OpenLayers.Layer.TMS("TMS", "http://mymapserver.com/MAP2/", { 'type': 'png', 'getURL': get_my_url });


      map.addLayer(layer);
      layer.redraw({ force: true });

      map.zoomToExtent(mapBounds);

    new OpenLayers.Control.Attribution(),
    new OpenLayers.Control.Zoom()

}




 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20130831/5529d470/attachment.html>


More information about the Users mailing list