[mapguide-internals] Problem with programatic changes of layers
VOLZ Mark (FN)
Mark.Volz at ergon.com.au
Wed Jun 2 00:20:50 EDT 2010
Folks,
I'm using the MGE 2010 (using a basic web layout) and I am having some
problems when I modifiy a layer via a piece of php (and I'm not getting
much joy from ADSK).
The scenerio;
1) From another app the user launches a mapguide session via a url call
which contains a unique id for the particualar piece of plant they wish
to view i.e.
http://<server_name>/mapguide2010/feederstat/navnet-switchzone.php?Paren
tId=60005615
2) The navnet-switchzone.php creates and logs into a mapguide session.
3) This page then calls another page passing the ParentID, session id, &
mapname variables.
4) The second page has 2 functions firstly to set a layer filter and
secondly to make that layer invisible in the layer legend.
5) The first page then zooms to the extents as calculated via an mbr
query on Oracle spatial.
Simple enough.
My problem is the second action of the second php page i.e. setting the
layer to invisible in the layer legend. It does do it after the user
performs a zoom or pan command but it is in the layer legend when the
page first loads which I don't want.
Things I have tried;
1) Adding the layer to the library map with the filter set to -1 and
turning off the layer legend visiblity. - no luck
2) doing a second zoom when the page is first loaded i.e. log into the
seession zoom to a scale of (truescale * 1.1) modify the layer then zoom
to true scale. - no luck
Any ideas?
Below is the code i am using to modify the layer.
Any help would be greatly appreciated.
Mark
// change HV_isol_dev_parent layer
$resId = new
MgResourceIdentifier('Library://FeederStat/Layers/HV_isol_dev_parent.Lay
erDefinition');
$byteReader = $resourceService->GetResourceContent($resId);
$layerXML = $byteReader->ToString();
$doc = DOMDocument::loadXML($layerXML);
$GridNode = $doc->getElementsByTagName('GridLayerDefinitionType');
$FilterNode = $doc->getElementsByTagName('Filter');
$FilterNode->item(0)->nodeValue = "ECORP_ASSET_ID = ".$parentId;
$LayerDefinition = $doc->saveXML();
$byteSource = new MgByteSource($LayerDefinition,
strlen($LayerDefinition));
$byteSource->SetMimeType(MgMimeType::Xml);
$layerName="HV_isol_dev_parent";
$sessionLayer =
"Session:".$sessionId."//".$layerName.".LayerDefinition";
$sessResId = new MgResourceIdentifier($sessionLayer);
$resourceService->SetResource($sessResId, $byteSource->GetReader(),
null);
$newLayer = new MgLayer($sessResId,$resourceService);
$newLayer->SetName($layerName);
$newLayer->SetVisible(true);
$newLayer->SetLegendLabel($layerName);
$newLayer->SetDisplayInLegend(false);
$layerCollection = $map->GetLayers();
$layerCount = $layerCollection->GetCount();
$modelLayerIndex = $layerCount-2;
if ($layerCollection->Contains("HV_isol_dev_parent"))
{
$selLayerIndex = $layerCollection->IndexOf("HV_isol_dev_parent");
$modelLayerIndex = $selLayerIndex;
$layerCollection->RemoveAt($selLayerIndex);
}
// Add Model layer to collection
if (! $layerCollection->Contains($layerName))
{
$layerCollection->Insert($modelLayerIndex,$newLayer);
// $layerCollection->Insert($layerCount-2,$newLayer);
}
*************************************************************************
This e-mail (including any attachments) may contain confidential or
privileged information and is intended for the sole use of the person(s) to
whom it is addressed. If you are not the intended recipient, or the person
responsible for delivering this message to the intended recipient, please
notify the sender of the message or send an e-mail to
mailto:help.desk at ergon.com.au immediately, and delete all copies. Any
unauthorised review, use, alteration, disclosure or distribution of this
e-mail by an unintended recipient is prohibited. Ergon Energy accepts no
responsibility for the content of any e-mail sent by an employee which is of
a personal nature.
Ergon Energy Corporation Limited ABN 50 087 646 062
*************************************************************************
More information about the mapguide-internals
mailing list