[maplab-users] Zoom to Point functionality

kgrootendorst at baird.com kgrootendorst at baird.com
Wed Feb 2 09:24:03 EST 2005

I'm trying to implement a zoom to point function, where by a user 
specifies a point (reach) number, clicks on a submit button, and the map 
will zoom to the point.
However, I'm having trouble with a GetShape statement.  Something isn't 
right.  The mapserver stops at this particular line of code:

$oShape = 

Below is my code for this feature.  You'll see that I still have to modify 
the code for zooming to a point rather than a polygon, but I haven't got 
that far yet.
I've searched the MapServer list and posted, but with no luck.  Using MS 
4.2, php 4.3.4.

Thanks in advance.



if (isset( $http_form_vars["doReachZoom"]) && 
($http_form_vars["doReachZoom"] > "0" ))
        //echo "zoom to reach";
        // the reach number to query for
        $szReachNumber = $http_form_vars["reachnum"];

        // the current extents will be the default if we fail.
        $oExtents = $oMapSession->oMap->extent;

        //first we need a handle on the layer, let's assume that we have
        //it's name
        $oReachLayer = $oMapSession->oMap->getLayerByName( "Reaches" );

        $oReachLayer->queryByAttributes("REACH", $szReachNumber, MS_SINGLE 
        //echo ("$szReachNumber");
        $results = $oReachLayer->getNumResults();
        //echo ("-- $results --");
        //now check to see if there are any results?
        if ($oReachLayer->getNumResults() > 0 )
                //echo " results2";
                //at least one result, assume only one for this example
                $oResult = $oReachLayer->getResult(0);
                //oResult is a resultCacheMemberObj
                echo " results3";   // THIS IS ECHOED
                $oShape = 
$oReachLayer->getShape($oResult->tileindex,$oResult->shapeindex); //  IS 
                echo " results4";  // THIS IS NOT ECHOED 
                $oExtents = $oShape->bounds;
                echo " results5";

                //at this point we might add a buffer to the extents
                $nXBuffer = ( $oExtents->maxx - $oExtents->minx )*0.05;
                $nYBuffer = ( $oExtents->maxy - $oExtents->miny )*0.05;
                $nMinX = $oExtents->minx - $nXBuffer;
                $nMaxX = $oExtents->maxx + $nXBuffer;
                $nMinY = $oExtents->miny - $nYBuffer;
                $nMaxY = $oExtents->maxy + $nYBuffer;
                $oExtents->setextent( $nMinX, $nMinY, $nMaxX, $nMaxY );
echo "oExtents have been set";
//      else{
//       echo " no results";}

        // now use $oMapNavigator to navigate to the parcel
        // location. There are two useful options now. We
        // can zoom to a rectangle which we have calculated or
        // to a point and scale. Let's assume we have calculated
        // a rectangle and put a buffer around it if necessary.
//      $height=$oMapSession->oMap->height;


        //$oMapNavigator->zoomRectangle($px1, $py2, $px2, $py1);

        // alternately if it's a point and a scale ...
        $oMapNavigator->zoomScale( 1000, 100, 100 );
echo "reach is null or negative";

Innovation, Excellence, & Service 
Oceans, Lakes & Rivers
Kevin Grootendorst 
905-845-5385 phone    905-845-0698 fax
627 Lyons Lane, Suite 200
Oakville, Ontario, Canada L6J 5Z7 
mailto:kgrootendorst at baird.com    http://www.baird.com/ 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/maplab-users/attachments/20050202/4fd176db/attachment-0001.html

More information about the Maplab-users mailing list