[MapQuery] adding layer changes extent

Justin Penka jpenka at sdrmaps.com
Tue Jun 21 11:22:37 EDT 2011


I would agree that it is not desirable to have the zoomToMaxExtent
function contained directly inside each layer object. I certainly do see
a need for the ability to set a zoom to max extent on the creation of
the map/or layer manager object, but a click event should not fire the
zoomToMaxExtent unless otherwise specified (ie zoomToMaxExtent button). 

I am not exactly sure in what case I would use it, but we could replace
the zoomToMaxExtent with a function that zooms to the extent of the
specified layer. Something like:

this.map.olMap.zoomToExtent(layerName.getDataExtent());

Although this does bring up the question: Is this a function that should
exist in the layer object at all? To me it seems that it is more logical
to make this a function of the map object but that's just my 2 cents.

-Justin


-----Original Message-----
From: mapquery-bounces at lists.osgeo.org
[mailto:mapquery-bounces at lists.osgeo.org] On Behalf Of Steven M. Ottens
Sent: Tuesday, June 21, 2011 9:41 AM
To: mapquery at lists.osgeo.org
Subject: [MapQuery] adding layer changes extent

  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



_______________________________________________
MapQuery mailing list
MapQuery at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapquery


More information about the MapQuery mailing list