[MapQuery] adding layer changes extent

Volker Mische volker.mische at gmail.com
Wed Jun 22 10:52:25 EDT 2011


+1 go for the fake base layer.

Cheers,
  Volker

On 06/21/2011 05:50 PM, Steven M. Ottens wrote:
>  It turns out to be quite a sticky situation. The
> olMap.zoomToMaxExtent() can only be called once there is a baselayer. As
> such you cannot call it from the Map object, since the Map object can be
> created without layers eg:
> var map = $('#map').mapQuery().data('mapQuery');
> map.layers({
>        type:'osm'
> });
> 
> After some experimenting and discussion on #openlayers I think the way
> to go is to add a fake baselayer by creation of the Map object. This has
> some impact though. For instance the openlayers overviewmap uses the
> baselayer if no layer is defined. However this can be solved in the
> mapquery widget I think. Using this approach all tests work, all
> examples work (except for the overview widget, since I haven't fixed
> that one yet)
> 
> Steven
> 
> On 6/21/2011 5:22 PM, Justin Penka wrote:
>> 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
>> _______________________________________________
>> MapQuery mailing list
>> MapQuery at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/mapquery
> 
> 
> _______________________________________________
> MapQuery mailing list
> MapQuery at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapquery



More information about the MapQuery mailing list