I am having an issue where I want to use zoomToMaxExtent(), but it isn't
showing the whole map (or in this case, an image). I notice that when it is
zoomed out but not far enough to show the whole image, it is returning the
zoom level as 0. I guess I cannot zoom negative, but why does it think this
is 0 zoom? all the images are the same number of pixels as their longest
dimension, so I don't know why there is so much difference in where zoom
level 0 is.

This is my code:

function render_details(artwork, markers){
        var img = new Image();
        img.src = artwork.detail;

        img.onload = function(){
                

                var artWidth = img.width;
                var artHeight = img.height;

                var maxExtent = new OpenLayers.Bounds(0, 0, artWidth,
                                artHeight);

                var graphic = new OpenLayers.Layer.Image(
                        'Title',
                        img.src,
                        //new OpenLayers.Bounds(150, 0, 1080, 240),
                        maxExtent,
                        new OpenLayers.Size(244, 
getDetailsY(artWidth,artHeight)),
                         {numZoomLevels: 4, isBaseLayer: true, ratio : 1.0}
                );

                map = new OpenLayers.Map('detailsdiv', {
                        projection : 'EPSG:3785',
                        units : 'm',
                        fractionalZoom : true,
                        maxResolution: Math.pow(2, graphic.numberOfTiers - 1),
                        numZoomLevels : graphic.numberOfTiers,
                        controls: [
                                 new OpenLayers.Control.TouchNavigation({
                                                dragPanOptions: {
                                                        enableKinetic: true
                                                }
                                 })
                        ]
                });


                
                map.addLayers([graphic]);

                //go back to where the map last was if mapbounds is set (as in 
when
returning from looking at pin details). BUG: will zoom one level back on
mobile, but not desktop.
                if (mapbounds){
                        map.zoomToExtent(mapbounds);
                        mapbounds = false;
                } else {

                        map.zoomToMaxExtent();
                        map.zoomOut();

                        //set maximum default zoom.
                        maxDefaultZoom = 9;
                        zoom = map.getZoom();
                        if (zoom > maxDefaultZoom){
                                map.zoomTo (maxDefaultZoom);
                        }
                }
        };
}



--
View this message in context: 
http://osgeo-org.1560.n6.nabble.com/zooming-out-past-0-or-making-zoom-0-display-whole-image-tp5035569.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
us...@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to