[OpenLayers-Users] OL Zoom Issue - Zoomed in very close, cannot not zoom out

Christopher Schmidt crschmidt at metacarta.com
Tue Aug 18 12:37:43 EDT 2009


On Tue, Aug 18, 2009 at 02:43:00PM +0100, Paul Curran wrote:
> Hi,
> 
> 
> 
> Been struggling with this problem for a little while now any help
> appreciated.
> 
> 
> 
> I can view my map of the UK fine via mapserver however when I view it via
> Openlayers I am zoomed in very close to the map (tree level). I am able to
> zoom in even closer (map becomes blurred) however i cannot zoom out. I only
> have one layer in the map file.
> 
> For my bounds I am using the extent from my map file
> 
> Here is my code
> 
> 
> 
>       *var zoom = 10;*
> 
>       var bounds = new OpenLayers.Bounds(0, 0, 660046, 1229782);
> 
>       var map, layer;
> 
> 
> 
> 
> 
>       function init(){
> 
>       map = new OpenLayers.Map('map', { *maxExtent: bounds, numZoomlevels:
> 10* });

  http://faq.openlayers.org/map/how-do-i-set-a-different-projection-on-my-map/

"""
There are three parameters in OpenLayers which are important to set if
you wish to change projections:

 * maxExtent
 * maxResolution
 * projection

maxExtent is the maximum bounds, in the units of your map, of the plane
in which you want to display information. maxResolution is the number of
mapunits per pixel at the highest zoom level, and the projection is used
when issuing WMS or WFS requests to inform the server of the projection
desired.
"""

You set one, but not the other two. The one that matters that you missed
is maxResolution.


> 
>       map.addControl(new OpenLayers.Control.PanZoomBar());
> 
>       map.addControl(new OpenLayers.Control.OverviewMap());
> 
>       map.addControl(new OpenLayers.Control.MousePosition());
> 
>       layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
> 
>       "http://127.0.0.1/cgi-bin/mapserv.exe?", { layers: 'uk', map:
> '/ms4w/apps/openlayers-2.5/data/uk1.map' },
> 
>       { gutter: 15 });
> 
>       map.addLayer(layer);
>       *map.zoomToExtent(bounds);*
> **
> Can anyone see where I am going wrong or have any suggestions?
> 
> 
> Cheers, thanks for any help in advance
> 
> Paul
> 
> p.s.   My mapfile is here
> 
> MAP
> 
>     NAME UK1
>  PROJECTION
>     "init=epsg:4326"
>  END
>     SIZE 1600 1200
>     IMAGECOLOR  153 204 255
>     IMAGETYPE JPEG
>     SHAPEPATH "http://localhost/openlayers/data/"
>     EXTENT  0 0 660046 1229782
>     UNITS DD
> 
> 
>  WEB
>    TEMPLATE "http://localhost/openlayers/examples/test.html"
>    LOG "\ms4w\tmp\ms_tmp\log.txt"
>       IMAGEPATH "\ms4w\tmp\ms_tmp\"
>       IMAGEURL "/ms_tmp/"
>       METADATA
>   'wms_title' "map"
>         'wms_onlineresource'  "http://127.0.0.1./cgi-bin/mapserv?map=uk1.map
> "
>       END
>  END
>   LAYER
> 
>     NAME "UK"
>     METADATA
>       'wms_title' "wms_demo"
>     END
>     STATUS DEFAULT
>     TYPE raster
>     TILEINDEX "map"
>     TILEITEM "Location"
>     PROJECTION
>       "init=epsg:4326"
>     END
>     CLASS
>       STYLE
>        COLOR 0 0 0
>       END
>       LABEL
>        COLOR 0 0 0
>        SIZE SMALL
>       END
> 
>     END
> 
>   END

> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users


-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list