[mapguide-users] Selecting features through PHP

George McLean gmclean at gorge.net
Thu Feb 1 15:40:58 EST 2007


Hello,

Is there a way to search the archives? Maybe my questions below has 
already been answered.

I have a php page the allows the user to enter some search criteria and 
then to zoom to a feature based on the search results. This seems to 
work pretty well by passing coordinates and zoom scale to the ZoomToView 
function. What I would like to do is highlight the selected feature so 
it is obvious which feature was selected. I thought I could add the 
feature to a selection set and it would show up as highlighted. So far I 
have not been able to get this to work.

My first question would be is this the best approach to highlight a 
feature?

If so, the following code snippet shows how I am attempting to add the 
feature to a selection set so it will be highlighted, maybe someone will 
have some insight as to why it is not working (or a better way to do 
this!).

Thanks in advance.

George

             $agfReaderWriter = new MgAgfReaderWriter();
             $aSelection = new MgSelection($map);
             $bFound = 0;
             while ($featureReader->ReadNext())
             {
                 $val = $featureReader->GetGeometry('geometry');
                 if ($val != NULL) {
                  $aGeometry = $agfReaderWriter->Read($val);
                  $aPoint = $aGeometry->GetCentroid();
                  $aCoord = $aPoint->GetCoordinate();
                  $x = $aCoord->GetX();
                  $y = $aCoord->GetY();
                  $aResourceId = new 
MgResourceIdentifier("Library://MapGuideStudio/Layers/Meters.LayerDefinition"); 

                  $aLayer = new MgLayer($aResourceId, $resourceService);
                  $aSelection->AddFeatures($aLayer, $featureReader, 1);
                  $aLayer->ForceRefresh();
                  $bFound = 1; // found coordinates                 } 
else {
                echo "This geometry property is null <br>";
             }



More information about the mapguide-users mailing list