[mapguide-users] Selecting a feature through PHP

Paul Spencer pspencer at dmsolutions.ca
Sat Feb 3 11:59:32 EST 2007


Its not obvious, but you need to save the selection:

$selection->Save($resourceService, $mapName);

Cheers

Paul

On 31-Jan-07, at 4:58 PM, George McLean wrote:

> Hello,
>
> 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>";
>              }
>
> _______________________________________________
> mapguide-users mailing list
> mapguide-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapguide-users

+-----------------------------------------------------------------+
|Paul Spencer                          pspencer at dmsolutions.ca    |
+-----------------------------------------------------------------+
|Chief Technology Officer                                         |
|DM Solutions Group Inc                http://www.dmsolutions.ca/ |
+-----------------------------------------------------------------+






More information about the mapguide-users mailing list