[maplab-users] ROSA PAN, and search by attaribute

Yifter Kidane Fikru fikru.yifter at unicatt.it
Fri May 21 09:56:12 EDT 2004


Dear Assefa,
 
In the ROSA applet, the zoom out and recenter functions don't work properly, I don't know why. Every time I click on them, the map defaults to the original extent. Is it my problem or  ... 
 
I would be glad if you shade light on how I can enhance the ROSA to have functionalities like PAN (which I have seen in previous lists not resolved), and zoom to selected feature.
 
Another problem I have is search feature by name. I implemented one of the suggested routines and the first time it worked fine. I never changed the code but I implemented other functionalities and after the search is not working anymore. I checked for variable inconsistency, but nothing. No error message too. What could be the reason? 
 
Here is the code I added to the main.php file:
 
if ($http_form_vars["village"])
{
 // the centri name to query for
 $szcentri = $http_form_vars["village"];
    // the current extents will be the default if we fail.
 $oExtents = $oMapSession->oMap->extent;
 $oldExtents = $oExtents;
    //first we need a handle on the layer, let's assume that we have
 //it's name
 $ocentriLayer = $oMapSession->oMap->getLayerByName( "Centri" );
 // set up the layer for a query in ms 3.6 - in 3.7 we don't need
 // to do this, we can just use querybyattribute. Here we assume
 // that the data file associated with the layer has an attribute
 // called centri_number that we are querying.
 $ocentriLayer->set( "filteritem", "NOME" );
 $ocentriLayer->setFilter("\"$szcentri\"");
 // use querybyattributes to generate the result, assume a single
 // one for simplicity but this can be extended to multiple
 // results easily
 if (@$ocentriLayer->queryByAttributes('NOME','/'.$szcentri.'/',MS_SINGLE) == MS_SUCCESS)
 {
  # $ocentriLayer->queryByAttributes('NOME','/'.$szcentri.'/',MS_SINGLE);
  //now check to see if there are any results?
  // if ($ocentriLayer->getNumResults() > 0 )
  // {
  //at least one result, assume only one for this example
  $oResult = $ocentriLayer->getResult( 0 );
  //oResult is a resultCacheMemberObj
  $ocentriLayer->open(); 
  //$ocentriLayer->open($oMapSession->oMap->shapepath);
  $oShape = $ocentriLayer->getShape($oResult->tileindex,$oResult->shapeindex);
  $oExtents = $oShape->bounds;
  $oShape->free();
  //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 );
 // }
        // HERE I NEED TO PUT SOMETHING IF THE RESULT TO THE QUERY IS ZERO??
        // 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.
  $breite=$oMapSession->oMap->width;
  $hoehe=$oMapSession->oMap->height;
  $px1=$breite/($oldExtents->maxx-$oldExtents->minx)*($oExtents->minx-$oldExtents->minx);
  $px2=$breite/($oldExtents->maxx-$oldExtents->minx)*($oExtents->maxx-$oldExtents->minx);
  $py1=$hoehe/($oldExtents->maxy-$oldExtents->miny)*($oldExtents->maxy-$oExtents->maxy);
  $py2=$hoehe/($oldExtents->maxy-$oldExtents->miny)*($oldExtents->maxy-$oExtents->miny);
  $oMapNavigator->zoomRectangle($px1, $py2, $px2, $py1);
  // alternately if it's a point and a scale ...
  //$oMapNavigator->zoomScale( 1000, 100, 100 );
 }
 # else
 
 # $oMapNavigator->zoomOut( 999999 );
 
}
 
My system is:
 
Mapserver Version 4.0.2 (2004-04-06)
Windows 2000 Server
 
Many Thanks
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 7718 bytes
Desc: not available
Url : http://lists.maptools.org/pipermail/maplab-users/attachments/20040521/57498c21/attachment.bin


More information about the Maplab-users mailing list