I'm using ms4w and working on my local machine and want to build a map like in the MapServer Example 1.9 (https://mapserver.org/tutorial/section1.html).
Unfortunately the HTML template doens't display the image of the map. The map images are only generated and saved in the tmp folder, but not shown in the browser.
My HTML template index.html looks like this:
<form name="mapserv" method="GET" action="http://127.0.0.1/cgi-bin/mapserv.exe">
<!-- HIDDEN MAPSERVER CGI VARIABLES -->
<input type="hidden" name="program" value="http://127.0.0.1/cgi-bin/mapserv.exe">
<input type="hidden" name="map" value="C:/MapServer-Project/myMap.map">
<input type="hidden" name="imgext" value="270353 5135877 931021 6201334">
<input type="hidden" name="imgxy" value="200 150">
<input type="hidden" name="zoom" value="0">
<input type="hidden" name="layer" value="airports">
<input type="hidden" name="mode" value="browse">
<div align="center">
<table border="1" cellpadding="0" cellspacing="0">
<tr>
<td>
<!-- THE INTERACTIVE, DYNAMICALLY CREATED MAP -->
<input type="image" name="img" src=[img] width="400" height="300">
</td>
</tr>
</table>
</div>
</form>
The web definiton in my mapfile myMap.map looks like this:
WEB
TEMPLATE 'index.html'
IMAGEPATH data/tmp/
IMAGEURL tmp
END
Folder structure:
-[]C
-[]MapServer-Project
-index.html
-myMap.map
-[]data
-[]tmp
I think there is a problem with relative paths. I think the img-tag in <input type="image" name="img" src=[img] width="400" height="300">
is not able to find the C:/MapServer-Project/data/tmp
folder.
For exmple somehow I can't use /cgi-bin/mapserv.exe
for <form name="mapserv" method="GET" action="http://127.0.0.1/cgi-bin/mapserv.exe">
. I have to use the http://127.0.0.1
prefix. Otherwise the application can't finde the file.
1 Answer 1
MS4W comes ready out-of-the-box with directories properly configured for the generated map images by MapServer (this is why I created MS4W, to prevent issues such as yours). For example, if you check the mapfile that you mention in the MapServer tutorial (available for download from https://mapserver.org/tutorial/background.html ), and open in Notepad++ the mapfile: C:/ms4w/apps/tutorial/htdocs/example1-9.map
you can see the proper settings for IMAGEPATH and IMAGEURL, that is used for all MS4W applications:
WEB
IMAGEPATH '/ms4w/tmp/ms_tmp/'
IMAGEURL '/ms_tmp/'
END
It is much easier to follow the exact same structure as the working MS4W applications, and create your project in the apps
folder in C:/ms4w/apps/project/mymap.map
and use the same settings as mentioned.
Of course since the MapServer tutorial is actually configured for MS4W (by me) you can actually extract the entire tutorial at the root of your drive at C:/ and restart Apache, and then follow the tutorial locally on your machine instead.
hint: if you haven't done it already, be sure to add color styling to mapfiles in your Notepad++ instance through https://ms4w.com/trac/wiki/Notepad++MapServerStyle
Happy mapserving!