[mapserver-users] Query from a text string

Ben Stewart stewartjb at agr.gc.ca
Wed Nov 27 07:51:19 EST 2002


Hello:

I am building a prototype for an application which highlights a polygon on a map, then downloads data from a remote URL.  The user clicks the map, and a download box pops up with the highlighted polygon on the map behind it.

The query is very straight forward.  The querymap displays, and a function retrieves the polygon label, in a CGI variable from the shapefile.  It uses java script to download an indexed dbase file with the same name as the label, from a remote URL.   

As a final step, I now want to take input from a text box and achieve the same functionality as I do when clicking on the map.   Retrieving the ZIP file, is no problem,  but as yet I am not able to bring up the query map.  Can anyone suggest on how I might go about doing this?  I notice that in a query string, the coordinates of a mouse click are usually passed to mapserver.  If I'm querying from a text string, I can't provide the coordinates of a click.  I can only provide the label, which as I mentioned is an attribute for that polygon.

Template and Mapfile are provided below if it would help you to look at them, but I am just looking for some direction.
Thank you, very much for your assistance.





<-----MAPFILE------------------------------------------------------------>
 


#
#Start of Map File - "core.map"
#
MAP
Name test
Status on
Size 240 165
Extent -2700000 -1175000 3500000 4500000
Units meters
Shapepath "data"
Symbolset symset.sym
Fontset  "/usr/www/httpd/htdocs/mapdata/style/fonts.txt"
 
 
WEB
TEMPLATE test.html
IMAGEPATH "/usr/www/httpd/htdocs/mapdata/tmp/"
IMAGEURL  "/mapdata/tmp/"
END  # web
 
 
QUERYMAP
 SIZE 240 165
 STATUS ON
STYLE HILITE
 COLOR 255 255 0
END #QUERYMAP
 
 
 
# Start of Layer Definitions
#
#
 
 
LAYER
NAME mapsheet
TYPE polygon
STATUS default
DATA "cliiwms"
TEMPLATE test.html
#TEMPLATE "http://sis.agr.gc.ca/cansis/nsdb/cli/cai[SHEET].zip"
 
CLASSITEM 'cli_ag'
CLASS
  NAME mapsheet
  EXPRESSION ([cli_ag] = 1)
  COLOR 255 255 204
  OUTLINECOLOR 000 000 000
END #CLASS
END #LAYER
 
 
 
 
LAYER                        #Display labels at a specific resolution
NAME mapsheetlabels
TYPE polygon
STATUS default
DATA "cliiwms"
MINSCALE 500000
MAXSCALE 12000000
#TEMPLATE "http://sis.agr.gc.ca/cansis/nsdb/cli/cai[SHEET].zip"
TEMPLATE test.html
LABELITEM "sheet"
 
CLASSITEM 'mapsheet'
CLASS
 NAME 'mapsheet'
 Expression ([cli_ag] = 1)
# COLOR 255 255 204
# OUTLINECOLOR 0 0 0
LABEL
   COLOR 66 33 0
   SIZE small
   FORCE on
 END #LABEL
 
END #CLASS
 
END # layer
 
 
 
 
LAYER
NAME themap
TYPE line
STATUS default
DATA "cliwmsp"
 
CLASS
 NAME 'details'
 COLOR 0 0 0
 OUTLINECOLOR 0 0 0
END #CLASS
END # layer
 
 
 
 
LAYER
NAME cities
TYPE point
STATUS default
DATA "citieswms"
MINSCALE 500000
MAXSCALE 12000000
LABELITEM "Name"
 
CLASSITEM 'name'
CLASS
 NAME 'City'
 SYMBOL "circle"
 SIZE 5
 COLOR 250 0 0
 LABEL
  COLOR 0 0 255
  SIZE small
  OFFSET 5 5
  POSITION auto
 END # label
END # class
END # layer
 
 
END #MAPFILE






<--------TEMPLATE------------------------------------------------------>





<html>
 
<head><title>Text Strings and Queries</title>
 
<Script language = "JavaScript">
 
function textquery(){                                                                                                      called from the form
      var sheet=document.theform.searchbox.value;
      window.location.href="http://sis.agr.gc.ca/cansis/nsdb/cli/cai"+sheet+".zip";
}
 
function checkquery() {                                                                                                   onLoad from body tag
var test = "[SHEET]";
  if (test.length > 0) {
    if (test.length < 5)
      window.location.href = "http://res.agr.ca/CANSIS/NSDB/CLI/cai[SHEET].zip";
  }
}
 </script>
</head>



<body onLoad="checkquery()">
 
 
<center>
<br><br>
<B>
My Little Text String Query
</B>
<br><br>
<form name="theform" method=GET action="/cgi-bin/mapserver/mapserv"
onSubmit="textquery()">
<center>
<table border=0 cellspacing=0 cellpadding=4 bgcolor="#cccccc">
  <tr><td valign="top">
 
<input type="image" name="img" SRC="[img]" width=240 height=165 border=0><br>
<input type="radio" name="mode" value="query">QUERY<br>
<input type="radio" name="mode" value="browse" checked>BROWSE<br>
<input type="text"  name="searchbox">&nbsp;&nbsp;
<input type="submit" value="gutcha">
 
<input type="hidden" name="imgxy" value="120 83">
<input type="hidden" name="imgext" value="[mapext]">
<input type="hidden" name="map" value="[map]">
<input type="hidden" name="mapext" value="shapes">
<input type="hidden" name="zoomdir" value="1">
<input type="hidden" name="zoomsize" value="2">
 
</form>
</td></tr>
</table>
</center>
</body>
</html>






More information about the mapserver-users mailing list