[mapguide-users] Selecting a feature through PHP

George McLean gmclean at gorge.net
Sat Feb 3 19:59:35 EST 2007


Thanks Paul,

Saving the selection seemed to do the trick.

Is there some way to control how the user selections work? I t seems 
difficult to select point objects. If I use a select window, I can 
select point objects but any line objects close by seem to get selected 
as well. I am assuming there is some kind of buffer outside of the 
selection window that hopefully I can adjust. It seems very difficult to 
just click on a point to select it. I am thinking I could build some 
sort of selection tool that mimics a small selection window but maybe 
there something like this already built? Any other suggestions on how to 
make it easier to select point features would be appreciated.

Thanks again,

George

Paul Spencer wrote:
> 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/ |
> +-----------------------------------------------------------------+
>
>
>
>
> _______________________________________________
> mapguide-users mailing list
> mapguide-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>
>



More information about the mapguide-users mailing list