[mapguide-users] Filtering features on map with SelectFeatures
function
James Card
James.Card at calcad.com
Thu Mar 29 13:36:00 EDT 2007
On Thu, 29 Mar 2007 08:27:15 -0700, FGoulet <gouletf at dfo-mpo.gc.ca> wrote:
> I want to limit (filter) the number of features visible for a layer on a
> map from server side code.
>
> I have aready successfully use the SelectFeatures function along with
> QueryOptions to select a set of features on the map.
>
> Now I would like to make the map shows only the features returned by the
> MgFeatureService.SelectFeatures function.
You'll probably want to modify the Filter element of the LayerDefinition
so that the layer displays only your desired objects. The code below does
that for one of our maps, but it isn't a very good example because it
updates the Library resource rather than the layer in the Session
repository.
$QueryFilter='Drawing+%3D+%26apos%3B74%26apos%3B+AND+Dept+%3D+%26apos%3B136%26apos%3B'
// Load the Query Match Layer Definition template into a PHP DOM object
and
// modify its Filter node so we're displaying the right building and
floor.
$doc = DOMDocument::load('QueryMatch.LayerDefinition.xml');
$FilterNode = $doc->getElementsByTagName('Filter')->item(0);
$FilterNode->nodeValue = $QueryFilter;
$LayerDefinition = $doc->saveXML();
$byteSource = new MgByteSource($LayerDefinition,
strlen($LayerDefinition));
$byteSource->SetMimeType(MgMimeType::Xml);
$tempResourceID = new
MgResourceIdentifier("Library://HumboldtFM/Layers/QueryMatch.LayerDefinition");
$resourceService->SetResource($tempResourceID, $byteSource->GetReader(),
null);
--
James Card
California CAD Solutions, Inc.
209 578-5580
More information about the mapguide-users
mailing list