[mapguide-users] Extending the functionality of built-in
commands (Ajax viewer)
gingerbbm
stuart.jones at jacobs.com
Thu Sep 11 13:25:37 EDT 2008
[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
>
--
View this message in context: http://n2.nabble.com/Extending-the-functionality-of-built-in-commands-%28Ajax-viewer%29-tp841643p1083220.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list