MapTools.org

[maplab-users] Zoom to polygons

Mark Balman Mark.Balman@birdlife.org.uk
Fri, 15 Nov 2002 15:37:14 -0000
Hi all

I have tried with some success at allowing a user to select a species from a
drop down list and then mapserver returns the requested species range
polygon. In my .map file I have placed the following layer:

LAYER
	NAME range
	DATA range
	STATUS OFF
	TYPE polygon
	FILTERITEM Spcspecies
	FILTER "%value%"
	CLASS
		COLOR 212 212 212
		OUTLINECOLOR 0 0 0
		TEMPLATE species_template.html
	END
END

In the initialise html page I have added the following  hidden objects:

<input type='hidden' name="mode" value="itemquery">
<input type='hidden' name="qlayer" value="range">
<input type='hidden' name="item" value="Spcspecies">

and also the select list:

Select species range:
<select name="value" size="1">
<option> COPRE
<option> BENG
<option> INDI
</select>

My problem is how to zoom to the selected value.. I have tried to integrate
this into an existing maplab/gmap prototype but without success. I have
tried using recommendations in the mailing list. I have tried putting the
following code (adapted from Andreas problem) into my dev_contents.php

<input type="hidden" name="mode" value="itemquery">
<input type="hidden" name="qlayer" value="range">
<input type="hidden" name="item" value="Spcspecies">
<!--------------------->
<!-- END HIDDEN VARS -->
<!--------------------->
Pick one:
<select name="value" size="1">
<option>  COPRE
<option>  BENG
<option>  INDI
</select>

and into my dev.php:

/*
============================================================================
 * Process navigation commands.
 * =========================================================================
*/
if($http_form_vars["value"])
 {
 $szSpcspecies=$http_form_vars["Spcspecies"];
 $oExtents=$oMapSession->oMap->extents;
 $oRangeLayer=$oMapSession->oMap->getLayerByName("range");
 $oRangeLayer->set("FILTERITEM","range");
 $oRangeLayer->setFilter($szSpcspecies);
 $oRangeLayer->queryByAttribute(MS_SINLGE);
 
 if($oRangeLayer->getNumResults()>0)
 $oResult = $oRangeLayer->getResult( 0 );
 $oShape = $oRangeLayer->getShape( $oResult->tileindex,$oResult->shapeid);
 $oExtents = $oShape->bounds;
 $oShape->free();
 }
 {
 $oMapNavigator->zoomRectangle;
 ($oExtents->minx, $oExtents->miny, $oExtents->maxx, $oExtents->maxy);
 }
 
Alas, still cannot get it to work, I am using the following setup:

php 4.2.1
maplab 2.0rc3
Apache
Win'98

Any ideas would be most welcome as I am banging my head with this one!

Cheers!

Mark Balman



This archive was generated by Pipermail.