[OpenLayers-Users] MapServer + OpenLayers

Luciano - Uol l.s.borges at uol.com.br
Tue Sep 23 14:31:26 EDT 2008


Hi all,

I'm trying to work with MapServer and OpenLayers, but I'm not able to do 
the map appear in OpenLayers.
Only the MapServer works well. I will post below the codes of the files 
that I'm working.

------bahia.map ------
MAP
SHAPEPATH "D:\MapServer\ms4w\Apache\htdocs\bahia\data\"
SYMBOLSET "D:\MapServer\ms4w\Apache\htdocs\bahia\symbols\simbo
los.sym"
IMAGECOLOR 255 255 255
IMAGETYPE png
EXTENT -46.7660 -18.8258 -37.2528 -8.3624
SIZE 480 500
STATUS ON
UNITS DD
NAME "GERAL"
DEBUG ON
PROJECTION
"init=epsg:42304"
END
WEB
IMAGEPATH "D:\MapServer\ms4w\Apache\htdocs\bahia\ms_tmp\"
IMAGEURL "/bahia/ms_tmp/"
END
LAYER
NAME "MunicipiosSelecionados"
DATA "Municipios"
STATUS DEFAULT
TYPE POLYGON
CLASS
OUTLINECOLOR 0 0 255
COLOR 255 0 0
END
END
END
-------- FIM DO CÓDIGO DO MAP ----------


If I call the URL:

http://localhost/cgi-bin/mapserv.exe?map=/mapserver/ms4w/Apache/htdocs/bahia/bahia.map&mode=map 


the map appears normally.

I created a page called exemplo3.jsp and I call this way:

http://localhost:8080/projetogis/exemplo3.jsp


------exemplo3.jsp ------

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#map {
border: 1px solid black;
}
</style>
<script src="js/OpenLayers.js"></script>
<script type="text/javascript">
function init(){
var options = {
projection: 'EPSG:42304'
};
var map = new OpenLayers.Map('map',options);
var layer = new OpenLayers.Layer.MapServer(
"Camada MapServer",
"http://localhost/cgi-bin/mapserv.exe",

{map:'/mapServer/ms4w/apache/htdocs/bahia/bahia.map'},
{isBaseLayer: true});
map.addLayer(layer);
map.zoomToMaxExtent();
}
</script>
</head>
<body onload="init()">
<div id="map"></div>
</body>
</html>

-------- END CODE ----------

The map don't appears.
When you click with right mouse button where was to be the image, has 
the following address:

http://localhost/cgi-bin/mapserv.exe?map=%2FmapServer%2Fms4w%2Fapache%2Fhtdocs%2Fbahia%2Fbahia.map&mode=map&map_imagetype=png&mapext=-90+-90+0+0&imgext=-90+-90+0+0&map_size=256+256&imgx=128&imgy=128&imgxy=256+256 


If I withdraw the attributes: mapext, imgext, map_size, imgx, imgy, imgxy
the map usually appears. Without these parameters the link is thus:

http://localhost/cgi-bin/mapserv.exe?map=%2FmapServer%2Fms4w%2Fapache%2Fhtdocs%2Fbahia%2Fbahia.map&mode=map&map_imagetype=png 



Does anyone have any tips?

Thanks, Luciano.




More information about the Users mailing list