[Mapserver-users] Itemquery - zooming to features

Mike Reilly mikereilly_7 at hotmail.com
Thu Jul 8 15:49:12 EDT 2004


David:

This works!

src="http://192.168.0.3/cgi-bin/mapserv.exe?map=[map]&name=[name_esc]&
mode=itemquerymap&mapext=shapes&qlayer=tuspoly&qstring=(SITEID=[SITEID])"

Thanks for all the help along the way, and may the archives turn this thread 
up for the next person needing it.  This isn't doing excactly what I need, 
but it's close enough to suffice.

I have a main map page that allows turning various layers on and off, 
zooming, etc, and I'd hoped to create a URL that would link back to that 
page and display just the one site a person was looking at, but I guess 
instead I'll make a popup link to create a couple of maps instead.

Regards
Mike
>From: "David Fawcett" <David.Fawcett at state.mn.us>
>To: <mikereilly_7 at hotmail.com>
>Subject: RE: [Mapserver-users] Itemquery - zooming to features
>Date: Thu, 08 Jul 2004 09:12:02 -0500
>
>Mike,
>
>What happens if you try:
>
><td><img border="2"
>src="[mapserv]?map=[map]&name=[name_esc]&mode=itemquerymap&mapext=shapes&qlayer=tuspoly&qstring=('[SITEID]'=1003)"
>height="300" width="300">
>
>OR
>
><td><img border="2"
>src="[mapserv]?map=[map]&name=[name_esc]&mode=itemquerymap&mapext=shapes&qlayer=tuspoly&qstring=('[SITEID]'='1003')"
>height="300" width="300">
>
>My guess is that the reason that you didn't get an error, but you also
>didn't return any records is that your qstring syntax isn't quite right.
>
>
>David.
>
>
>
>David J. Fawcett
>MN Office of Environmental Assistance
>
> >>> "Mike Reilly" <mikereilly_7 at hotmail.com> 7/8/2004 3:03:06 AM >>>
>Thanks Javier and Adam - you both got me past that error - and on to
>the
>next one:
>
>msQueryByAttributes(): Search returned no results. No matching
>record(s)
>found.
>
>And after re-reading Javier's response to me, I found that using the
>following did the trick:
>
>qstring=([SITEID]=1003)
>
>At first I tried qstring=([SITEID]="1003") but got a lot of parse fails
>
>along with the error message.  It now looks like I'm getting the
>results I
>need, although I'm not getting the maps drawn yet.   No images created
>in
>the /tmp/ directory.
>
>I'm including a copy of the template file in case I've made an error in
>it.
>
> >From: Javier Castillejo Montes <jcastil1 at tragsa.es>
> >To: Mike Reilly <mikereilly_7 at hotmail.com>
> >CC: mapserver-users at lists.gis.umn.edu
> >Subject: RE: [Mapserver-users] Itemquery - zooming to features
> >Date: Thu, 8 Jul 2004 09:11:19 +0200
> >
> >Hi Mike
> >I had the same problem and "David Fawcett" told me the solution...
>here it
> >is
> >
> > >>>>The syntax for itemqueries changed after version 3.5 or so.
> >
> > >>>>Queries no longer use a filter in the Map file.  Instead, you
>need to
> > >>>>pass the variables 'qlayer', 'qitem', and 'qstring' in the URL.
>They
> > >>>>are documented here:
> > >>>>http://mapserver.gis.umn.edu/doc42/cgi-reference.html#qitem
> >
> > >>>>It should look something like:
> >
> > >>>>...&qlayer=layer1&qitem=FIELD2&qstring=('[FIELD2]'='10')
> >
> > >>>>&qlayer=provin&qitem=NOMBRE&qstring='Juarez'
> >
> > >>>>(This assumes that there is a 'provin' with the name 'Juarez'.
>If you
> > >>>>build this URL string dynamically in the form at the bottom of
>this
> > >>>>message, it should look something like this:
> >
> > >>>><td><img border="2"
> > >>>>src="[mapserv]?map=[map]
> >
> >>>>&name=&mode=itemquerymap&mapext=shapes&qlayer=provin&qitem=NOMBRE&qstrin
> >g='[name_esc]'
> > >>>>" height="300" width="300"></td>
> >
> >
> >my "end" map file!!
> >
> >   LAYER
> >     NAME provin
> >     DATA provin
> >     STATUS DEFAULT
> >     TYPE POLYGON
> >     FILTERITEM nombre
> >     CLASS
> >       COLOR 212 212 212
> >       OUTLINECOLOR 0 0 0
> >       TEMPLATE "../html/case1_template.html"
> >     END
> >   END
> >
> >my html snip
> >...
> ><input type="hidden" name="mode" value="itemquery">
> ><input type="hidden" name="qlayer" value="provin">
> >
> ><input type="hidden" name="qitem" value="Prov">
> ><input type="hidden" name="qstring" value="[name_esc]">
> >...
> >
> >
> >Hope It will help you, for me it works...
> >
> >
> >Javier C.
> >
> >
> >-----Mensaje original-----
> >De: Mike Reilly [mailto:mikereilly_7 at hotmail.com]
> >Enviado el: jueves, 08 de julio de 2004 0:38
> >Para: mapserver-users at lists.gis.umn.edu
> >Asunto: [Mapserver-users] Itemquery - zooming to features
> >
> >
> >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+g
> >roup%2Fapache2%2Fhtdocs%2FKitasoo%2Fquerytest.map&map_web_imagepath=f%3A%2Fp
> >rogram+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&qla
> >yer=[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=htt
>
> >p://hotmail.com/enca&HL=Market_MSNIS_Taglines
>
>_________________________________________________________________
>MSN Premium includes powerful parental controls and 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

_________________________________________________________________
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




More information about the mapserver-users mailing list