This is one of the things that is special about MapGuide, and, IMO, not
well explained in the user guide.
When you create the runtime map, the runtime map becomes a binary copy
of the MapDefinition.
The runtime map has everything from the MapDefinition and some of the
data from the LayerDefinition
of each layer.
Some properties has to be changed in the runtime map, others have to be
changed in the LayerDefinition.
The runtime map never reads anything from the MapDefinition (AFAIK), so
you will not get anything
out of changing the MapDefinition after the runtime map has been generated.
This is largely what you should do instead (replace with code after the
first three lines):
$map = new MgMap();
$map->Open(resourceService, $mapName);
$map->GetLayers()[0]->Visible = true;
$map->Save($resourceService, $mapName);
Regards, Kenneth Skovhede, GEOGRAF A/S
gingerbbm skrev:
[This question is off the back of
http://n2.nabble.com/RE%3A-Bypassing-initial-view-at-startup-td790257.html
this thread .]
I have successfully intercepted the call to mapagent.fcgi with a call to my
own PHP page (let's call it "bespoke.php"). I build a querystring of all the
POST or GET parameters and simply redirect at the end of bespoke.php like
so:
$url = "mapagent.fcgi?" . $querystring;
header("Location: $url");
exit();
That works nicely.
Ultimately, before redirection occurs, I want to alter the feature class of
one of the layers, but for now I'm just trying to toggle the visibility of
one (via the MapDefinition) to prove the point. I simply read in the map
definition as XML, tweak it, then write it back:
$siteConnection = new MgSiteConnection();
$siteConnection->Open(new MgUserInformation($sessionId));
$resourceService =
$siteConnection->CreateService(MgServiceType::ResourceService);
// Use MapDefinition from the Session
$mdResourceId = new
MgResourceIdentifier("Session:$sessionId//$mapName.MapDefinition");
$mdReader = $resourceService->GetResourceContent($mdResourceId);
$mdXml = $mdReader->ToString();
$mdDomDoc = DOMDocument::loadXML($mdXml);
$node = $mdDomDoc->getElementsByTagName("Visible")->item(1);
$node->nodeValue = "false";
$mdUpdatedXml = $mdDomDoc->saveXML();
$mdByteSource = new MgByteSource($mdUpdatedXml, strlen($mdUpdatedXml));
// Overwrite
$resourceService->SetResource($mdResourceId, $mdByteSource->GetReader(),
null);
Although I can confirm that the MapDefinition in the Session is changing as
expected (by interrogating http://.../mapguide/mapagent/index.html), the
map's appearance does not change as expected when it redraws.
Any ideas why not?
Thanks
Stuart
Kenneth Skovhede, GEOGRAF A/S wrote:
I'm sure it can be done.
However, it seems fairly advanced.
I would suggest that you have a look at OpenLayers:
http://openlayers.org
With OpenLayers, you can have your MapGuide map as a base layer,
and then put an overlay with your custom layer.
You can then override the mapagent path in the overlay to point to your
customization page, rather than mapagent.fcgi.
If you want to stick with the WebLayout based you will most likely get
better results with a manually added overlay image.
The problem with the manual approach is passing on events to the image
below.
Another option would be to have all calls to mapagent.fcgi point to your
PHP script, and then make the script
act as a relay page for those calls that you are not interrested in.
Regards, Kenneth Skovhede, GEOGRAF A/S
_______________________________________________
mapguide-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapguide-users