[MapQuery] adding layer changes extent

Steven M. Ottens steven at minst.net
Tue Jun 21 10:41:12 EDT 2011


  Hi all,

I noticed when working on the new mqLayerManager widget that this:
     $("p").click(function() {
         jQuery('#map').data("mapQuery").layers({
             type:'bing',        //create a bing maps layer
             view:'satellite',    //use the bing satellite (aerial) 
layer, instead of bing road (default)
             
key:'ArAGGPJ16xm0RXRbw27PvYc9Tfuj1k1dUr_gfA5j8QBD6yAYMlsAtF6YkVyiiLGn'
             });
         });

changes the extent of the map. This is obviously not desirable. The 
problem here is the layer option zoomToMaxExtent: true. Disabling this 
fixes the problem, however most of the examples will not show a map, 
since they require zoomToMaxExtent set on the layer.

So with some more digging I found that mapquery does this in the Layer 
object:
if (options.zoomToMaxExtent) {
         this.map.olMap.zoomToMaxExtent();
     }

I don't think this should be in the layer object. It does not make sense 
that a layer zooms to the maxextent of the map. it might be that there 
is a function where you can zoom to the maxextent of the layer, but 
that's something different and def. not olMap.zoomToMaxExtent();

I'd like to propose to remove the zoomToMaxExtent option from the Layer 
object and somehow make sure that the map zooms to maxExtent when 
created (unless otherwise specified)

any thoughts?
Steven





More information about the MapQuery mailing list