[Mapserver-users] Itemquery - zooming to features

Mike Reilly mikereilly_7 at hotmail.com
Wed Jul 7 18:37:38 EDT 2004


This is a multi-part message in MIME format.

------=_NextPart_000_3fbc_7fb0_6d45
Content-Type: text/plain; format=flowed

I have a mapserver application running quite nicely and now want to add the 
ability to create a link that brings up a map zoomed in to a feature based 
on that features SITEID field in a dbf file.  This feature is similar to 
that shown at this tutorial in case 1: 
http://maps.dnr.state.mn.us/mapserver_demos/tests40/itemquery/test.html

To that effect, I've basically copied the tutorial and placed in my own 
customisations to make it work with my data.  So far I've not been terribly 
succesful and get the following error:

msQueryByAttributes(): Query error. No query expression defined.

There is most definitely a field called SITEID in the dbf file for the 
mergeplys layer.  There is also a record with a SITEID of 1003.

I am using mapserver 4.0 windows binary distribution.

The URL that gets generated looks like this:

http://192.168.0.3/cgi-bin/mapserv.exe?mapserv=f%3A%2Fprogram+files%2Fapache+group%2Fapache2%2Fcgi-bin%2Fmapserv.exe&map=f%3A%2Fprogram+files%2Fapache+group%2Fapache2%2Fhtdocs%2FKitasoo%2Fquerytest.map&map_web_imagepath=f%3A%2Fprogram+files%2Fapache+group%2Fapache2%2Ftmp&map_web_imageurl=%2Ftmp%2F&mode=itemquery&qlayer=tuspoly&site_id=1003

I'm pretty sure I'm missing something basic somewhere.  One issue (I don't 
think this is what is causing the error message) is found in the template 
file.  I'm not quite sure what to do with some of the variables in this 
spot:

src="[mapserv]?map=[map]&name=[name_esc]&mode=itemquerymap&mapext=shapes&qlayer=[qlayer]"
- I assume I need to change some of the values here.   Any advice or 
pointers to documentation greatly appreciated.

The mapfile I created looks like this:

MAP
  NAME case1
  SHAPEPATH tus
  SIZE 300 300
  EXTENT 768897.25886 810841.50306 876598.91242 913853.62854

  WEB
    IMAGEPATH 'f:/program files/apache group/apache2/htdocs/tmp/'
    IMAGEURL 'http://192.168.0.3/tmp/'
  END

  QUERYMAP
    STATUS ON
    STYLE HILITE
    COLOR 255 255 0
  END

  LAYER

    NAME "landpl"
    DATA "landpl"
    STATUS DEFAULT
    TYPE POLYGON
    CLASS
      COLOR 212 212 212
      OUTLINECOLOR 0 0 0
    END
  END

  LAYER
    NAME tuspoly
    DATA "mergeplys"
    STATUS ON
    TYPE POLYGON
    FILTERITEM SITEID
    FILTER "%site_id%"
    CLASS
	COLOR 160 160 255
    	OUTLINECOLOR 0 200 0
	TEMPLATE case1_template.html
    END
  END
END

My HTML file used to generate the URL should be attached (I hope!).

_________________________________________________________________
Add photos to your e-mail with MSN Premium. Get 2 months FREE*  
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines

------=_NextPart_000_3fbc_7fb0_6d45
Content-Type: text/html; name="testquery.html"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="testquery.html"

<html>
<head>
  <title>MapServer Test Suite - ItemQuery</title>
  <script language="javascript" src="config.js"></script>
  <script language="javascript">
	  var id = new Array('1001','1002','1003','1004','1005');

    function write_counties() {
      var i;

      for(i=0; i<id.length; i++)
      document.write("<option> " + id[i] + "\n");
    }

    function submit_case2() {
      var i, sep='';

      document.case2.map_county_filter.value = '/'; // start of a regex
      for(i=0; i<document.case2.id.length; i++) {
        if(document.case2.name.options[i].selected)
          document.case2.map_county_filter.value = document.case2.map_county_filter.value + sep + document.case2.name.options[i].text;
          sep = '|';
      }
      document.case2.map_county_filter.value += '/'; // end of a regex
    }
  </script>
</head>

<body bgcolor="#ffffff">


<script language="javascript">
  document.write("<font size=\"+2\" face=\"arial,helvetica\"><b>MapServer <a href=\"" + htmlroot + "\">Test Suite</a> - ItemQuery</b></font>");

</script>

<p>

<font size="+1" face="arial,helvetica"><b>Case 1: Simple ItemQuery With QueryMap</b></font>

<p>
<a href="querytest.map"><i>map file</i></a><br>
<a href="case1_template.html"><i>query template file</i></a>
<p>

<script language="javascript">
	document.write("<form name=\"case1\" method=\"get\" action=\"../../cgi-bin/mapserv.exe\">\n\n");
  document.write("<input type=\"hidden\" name=\"mapserv\" value=\"" + mapserv + "\">\n");
  document.write("<input type=\"hidden\" name=\"map\" value=\"" + root + "querytest.map\">\n");
  document.write("<input type=\"hidden\" name=\"map_web_imagepath\" value=\"" + imagepath + "\">\n");
  document.write("<input type=\"hidden\" name=\"map_web_imageurl\" value=\"" + imageurl + "\">\n");
</script>

<input type="hidden" name="mode" value="itemquery">
<input type="hidden" name="qlayer" value="tuspoly">

Pick one:

<select name="id" size="1">
<script language="javascript">write_counties()</script>
</select>

<input type="submit" value="Go!">

</form>

<p><hr noshade><p>
</body>
</html>


------=_NextPart_000_3fbc_7fb0_6d45--



More information about the mapserver-users mailing list