[OpenLayers-Dev] overviewmap and spherical mercator

Steven M. Ottens steven at minst.net
Wed Sep 26 10:34:13 EDT 2007


Hm, it looks like openlayers handles a lot in lonlat bounds, not a bad 
idea, but the function
getZoomForExtent: function(extent) {
 var viewSize = this.map.getSize();
 var idealResolution = Math.max( extent.getWidth() / viewSize.w,
 extent.getHeight() / viewSize.h );

returns the resolution 2 in this way for an overviewmap of the entire 
world and 180px wide (360/180)

However Google maps in spherical mercator has resolutions ranging from:
156543 to 0.29 so 2 is not a good resolutoin for showing the entire 
world as such

return this.getZoomForResolution(idealResolution); returns the wrong 
zoomlevel!
Either I'm doing something fundamentally wrong, or this is something 
fundamental in the code

Steven

Andrew Hughes wrote:
> Could the overview be receiving degree's instead of meters from the 
> map object?
>
>
> On 9/26/07, *Steven M. Ottens* < steven at minst.net 
> <mailto:steven at minst.net>> wrote:
>
>     Steven M. Ottens wrote:
>     > Hi All,
>     >
>     > I'm trying to implement an overviewmap together with a google
>     layer,
>     > using the spherical mercator code by Tim. However, it fails with
>     an error:
>     > 'bounds has no properties' in the function zoomToExtent in Map.js
>     > This function is called from zoomToMaxExtent and it uses
>     > this.getMaxExtent() to get a bounds. However this last function
>     returns
>     > null. this.maxExtent at this point is -180,-90,180,90 which I
>     believe is
>     > the default maxExtent, since it's wrong, tims foss4g sandbox
>     only shows
>     > North America and last time I checked that doesn't span the globe ;)
>     > If I go into getMaxExtent at this point it tells me that
>     this.baseLayer
>     > = null. At this point I don't know what to do. There is a
>     baseLayer so I
>     > don't understand why in the overviewMap it doesn't show. Or when
>     that's
>     > correct behavior, why it fails on a lack of bounds.
>     >
>     > Anyone has an overviewmap working with the Spherical Mercator
>     > projection, if so could you please enlighten me?
>     >
>     I've been trying some more and I do have an overviewmap, except it's
>     showing the wrong extent:
>     I've added the overviewmap to google-sm.html this way:
>
>       var options2 = {
>                     projection: "EPSG:900913",
>                     units: "m",
>                     layers: [google],
>                     maxExtent: new OpenLayers.Bounds (
>
>                       -16710968, 391357,
>                     -4970241, 8218508)
>         };
>         var overview = new OpenLayers.Control.OverviewMap(options2);
>
>         map.addControl(overview);
>
>     But the overviewmap shows a bit of the southern hemisphere in
>     stead of
>     the correct extent
>
>     regards,
>     Steven
>
>     > Regards,
>     > Steven
>     >
>     >
>     > _______________________________________________
>     > Dev mailing list
>     > Dev at openlayers.org <mailto:Dev at openlayers.org>
>     > http://openlayers.org/mailman/listinfo/dev
>     >
>
>
>
>     _______________________________________________
>     Dev mailing list
>     Dev at openlayers.org <mailto:Dev at openlayers.org>
>     http://openlayers.org/mailman/listinfo/dev
>
>






More information about the Dev mailing list