[mapguide-users] Clearing Selections
Scott Hameister
ScottH at mPower-tech.com
Sat Dec 9 00:38:01 EST 2006
I'm using this code from the Developers book , It' works fine, except it
grabs the correct objects, but doesn't release objects already selected.
How do I clear out the Selection in advance so that ONLY my new FILTERED
objects are in the selection.
Is there a selection.Clear() or selection.Remove() option to the webAPi
besides for only Adds.
I can't call the parent.mapFrame.ClearSelection() with javascript, because
it runs after the page has compiled and deletes the selection after its been
created.
$queryOptions = new MgFeatureQueryOptions();
$queryOptions->SetFilter("RNAME LIKE 'Schmitt%'");
$queryOptions->SetSpatialFilter('SHPGEOM',
$districtGeometry,
MgFeatureSpatialOperations::Inside);
// Get the features from the feature source,
// turn it into a selection, then save as XML.
$featureResId = new MgResourceIdentifier(
"Library://Samples/Sheboygan/Data/Parcels.FeatureSource");
$featureReader = $featureService->SelectFeatures(
$featureResId, "Parcels", $queryOptions);
Example: Setting the Active Selection | 53
$layer = $map->GetLayers()->GetItem('Parcels');
$selection = new MgSelection($map);
$selection->AddFeatures($layer, $featureReader, 0);
$selectionXml = $selection->ToXml();
echo 'Setting selection...';
}
catch (MgException $e)
{
echo $e->GetMessage();
echo $e->GetDetails();
}
?>
</body>
<script language="javascript">
<!-- Emit this function and assocate it with the onLoad event -->
<!-- for the page so that it gets executed when this page loads-->
<!-- in the browser. The function calls the SetSelectionXML -->
<!-- method on the Viewer Frame, which updates the current -->
<!-- selection on the viewer and the server. -->
function OnPageLoad()
{
selectionXml = '<?php echo $selectionXml; ?>';
parent.parent.SetSelectionXML(selectionXml);
}
</script>
</html>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-users/attachments/20061208/98a20a08/attachment.html
More information about the Mapguide-users
mailing list