[mapguide-users] Add layer dinamically from search results
Mauricio Villablanca
mgvillablanca at yahoo.com
Tue Feb 26 19:01:00 PST 2013
An approach to this is to create a session layer. Basically get the layer
definition of your data source then add a filter to it, create a layer with
it and add it to the session repository.
In PHP
//get defintiion
$layer = $layers->GetItem($layerName);
$layerDefinition = $layer->GetLayerDefinition();$source_resourceID = new
MgResourceIdentifier($layerDefinition->ToString());
$destination_resourceID = new MgResourceIdentifier("Session:
new.LayerDefinition");
$resourceService->CopyResource($source_resourceID, $destination_resourceID,
true);
$newLayer = new MgLayer($destination_resourceID, $resourceService);
//modify definition of new layer
$layerDefinitionToChange = $newLayer->GetLayerDefinition();
$byteReader =
$resourceService->GetResourceContent($layerDefinitionToChange); //xml file
$XMLContent = $byteReader->ToString();
//put the xml in the DOM and edit
$domDocument = DOMDocument::loadXML($XMLContent);
$xpath = new DOMXPath($domDocument);
//change the filter
$firstQuery = '//VectorLayerDefinition/Filter';
// Get a list of all the <VectorLayerDefinition><Filter> elements in the
XML.
$filterNodes = $xpath->query($firstQuery);
etc
--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Add-layer-dinamically-from-search-results-tp5033775p5037137.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list