[mapguide-users] Clearing Selections
Trevor Wekel
trevor.wekel at autodesk.com
Wed Dec 13 16:29:33 EST 2006
Hi Scott, You are correct. There are no APIs to Clear() or Remove()
selections. Would creating an empty selection work in your case?
$selection = new MgSelection($map);
$selectionXml = $selection->ToXml();
_____
From: Scott Hameister [mailto:ScottH at mPower-tech.com]
Sent: Friday, December 08, 2006 10:38 PM
To: users at mapguide.osgeo.org
Subject: [mapguide-users] Clearing Selections
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/20061213/dcba5f70/attachment.html
More information about the Mapguide_users
mailing list