[mapserver-users] Openayers - Map zoomed in to much
Brent Fraser
bfraser at geoanalytic.com
Wed Jul 22 06:53:39 PDT 2009
Paul,
The PROJECTION, EXTENT, and UNITS objects in the map file are closely
related. If the PROJECTION is geographic (as yours is), you need to set the
UNITS to DD and the EXTENT to something in that coordinate system, eg:
PROJECTION # a spherical coordinate system
"init=epsg:4326"
END
UNITS DD # Decimal Degrees
EXTENT -11 50 2 60 # UK extent in degrees
and in your Javascript:
var bounds = new OpenLayers.Bounds(-11,50, 2, 60);
Best Regards,
Brent Fraser
Paul Curran wrote:
> Hi,
> I am having trouble viewing my map correctly via open layers, the map is
> zoomed in very close I cannot zoom out anymore.
> I have tried different zoom extents however it is the same. Can anyone
> tell me where I am going wrong is it the epsg code? If I enter a
> different epsg code I just see the background colour of my map file.
> Andy help greatly appreciated
> My map and openlayers files are below
> Thanks
>
>
> MAP
>
> NAME UK1
> PROJECTION
> "init=epsg:4326"
> END
> SIZE 1600 1200
> IMAGECOLOR 153 204 255
> IMAGETYPE JPEG
> SHAPEPATH "http://localhost/openlayers/data/"
> EXTENT -8883850.321101 -310000.000000 15483850.321101 12710000.000000
> UNITS METERS
>
>
> 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' "wms demo"
> 'wcs_onlineresource'
> "http://127.0.0.1./cgi-bin/mapserv?map=/ms4w/apps/openlayers-2.5/data/uk1.map&"
> 'wms_srs' "epsg:4326 epsg:4269"
> 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
> END
>
> <html xmlns="http://www.w3.org/1999/xhtml">
> <head>MAPPING TEST
> <style type="text/css">
> #map {
> width: 90%;
> height: 90%;
> border: 8px solid black;
> }
> </style>
> <script src="../lib/OpenLayers.js"></script>
> <script type="text/javascript">
> var zoom = 1;
> var bounds = new OpenLayers.Bounds(-888385.321101, -31000.000000,
> 1548385.321101, 1271000.000000);
> var map, layer;
>
> function init(){
> map = new OpenLayers.Map('map', { maxExtent: bounds });
> 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);
> map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
>
> }
> </script>
> </head>
> <body onload="init()">
> <div id="map"></div>
> </body>
> </html>
>
> ------------------------------------------------------------------------
> Share your memories online with anyone you want. Learn more.
> <http://clk.atdmt.com/UKM/go/134665338/direct/01/>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
More information about the MapServer-users
mailing list