I want to display a MapServer raster image with OpenLayers 2. My problem is that I cannot zoom into the image although the resolution should allow it.
This is what I have so far: http://geocre.net/mapservertest/
A detail of the original image:
HTML code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<title>OpenLayers MapServer Test</title>
<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/openlayers/2.13.1/theme/default/style.css" media="all" />
<style>
html { width:100%; height:100%; margin:0; }
body { width:100%; height:100%; margin:0; font-family:sans-serif; }
#map { width:100%; height:100%; margin:0; }
</style>
</head>
<body>
<div id="map"></div>
<script src="//cdnjs.cloudflare.com/ajax/libs/openlayers/2.13.1/OpenLayers.js"></script>
<script>
// set projection:
var projData = new OpenLayers.Projection("EPSG:4326");
var projDisplay = new OpenLayers.Projection("EPSG:900913");
// initialize map:
var map = new OpenLayers.Map('map', { projection:projDisplay, controls:[new OpenLayers.Control.Zoom(), new OpenLayers.Control.Navigation({'zoomWheelEnabled':true}), new OpenLayers.Control.ScaleLine()] } );
// set basemap:
var rasterLayer = new OpenLayers.Layer.MapServer("Tamale (wet season)", "http://78.47.251.2/cgi-bin/mapserv", {map:'/mapserver/tamale_ws.map'});
map.addLayer(rasterLayer);
// set map center:
map.setCenter(new OpenLayers.LonLat( -0.83945,9.3833).transform(projData, projDisplay), 15);
</script>
</body>
</html>
MapServer map file:
MAP
IMAGETYPE JPEG
EXTENT -94018 1048833 -92362 1049470
SIZE 1000 400
WEB
METADATA
"wms_title" "mymap"
"wms_srs" "epsg:900913"
END
END
LAYER
METADATA
"wms_title" "mymap"
"wms_srs" "epsg:900913"
"wms_enable_request" "*"
END
NAME myraster
DATA /mapserver/data/tamale_wet_season.tif
STATUS DEFAULT
TYPE RASTER
PROCESSING "BANDS=1,2,3"
OFFSITE 0 0 0
END
END
"wms_enable_request" "GetMap GetCapabilities"
in theMETADATA
section of your mapfile?