[mapguide-users] MapAgent parameters
Trevor Wekel
trevor.wekel at autodesk.com
Thu Mar 30 19:36:36 EST 2006
Hi Andy, Hi list,
As you have found out USERNAME, PASSWORD, and SESSION are all valid HTTP
request arguments. USERNAME and PASSWORD are not "officially" supported
since they are clear text arguments but I am checking with the team to
see if we should support it officially. Obviously it is quite useful.
The SESSION argument is very powerful. When an authenticated user
creates a session identifier (through Studio, the Viewers, API, etc), a
temporary data store is created for the user. This datastore is called
the session repository. Virtually anything could be stored there using
the MgResourceService APIs - either via HTTP, or via php/aspx/jsp
script. The session identifier is a guid similar to
"923e3fff-ffff-ffff-8000-005056c00008"
When a map is displayed through the viewers, a temporary runtime object
is created in the session repository for that map. This runtime object
can be manipulated from script or HTTP calls to change the view state of
the map. The view state includes the visible layers, the scale factor,
the map center point, etc. Walt gave a short introduction to modifying
the state via HTTP in his email.
For additional information on modifying the runtime map via script, take
a look at the buffer.php/aspx/jsp script in the mapviewerphp/net/java
folders. It does some manipulation on MgMap. MgMap is the API object
that gives access to the runtime map. Here's a short snippet of PHP
code with some interesting bits.
$cred = new MgUserInformation($sessionId);
$site = new MgSiteConnection();
$site->Open($cred);
$resourceSrvc = $site->CreateService(MgServiceType::ResourceService);
//load the map runtime state
$map = new MgMap();
$map->Open($resourceSrvc, $mapName);
By default, runtime maps are created at the root of the user's session
repository using the basename of the resource identifier for the map.
For example, if your map definition is located at
Library://ProfessionalDeveloper/ExcellentMap.MapDefinition
Then the $mapName argument should be "ExcellentMap". MgMap.Open will
use the session identifier specified in the call to
MgSiteConnection.Open. Just as an example, the full resource identifier
for the runtime map will be "Session:(guid)//ExcellentMap.Map".
MgMap.Open creates this resource identifier using the $mapName and
sessionId.
You can use
$map->GetLayers()
to get a list of the layers on the map, manipulate the layers, and then
save the new runtime state back to the session repository using
$map->Save($resourceSrvc);
The script you are building may also need to "kick" the viewer side to
force an update on the map. This is accomplished by sending some
JavaScript back in the HTTP response.
<html>
</body onload="parent.mapFrame.Refresh()"></body>
</html>
Selection is stored as a separate object in the session repository under
"Session:(guid)//ExcellentMap.Selection"
Selection can be programmatically accessed and modified via
MgSelection.Open($resourceSrvc, $mapName);
MgSelection.Save($resourceSrvc, $mapName);
-----Original Message-----
From: Andy Morsell [mailto:amorsell at spatialgis.com]
Sent: Thursday, March 30, 2006 11:59 AM
To: users at mapguide.osgeo.org
Subject: RE: [mapguide-users] MapAgent parameters
Another cool thing I just discovered along these lines. If you have
programmatically created a selection object on the server as part of a
session, if you pass the SESSION at the URL, it will draw the selection.
In this case, since the session is already validated, you do not need to
pass username or password nor are you prompted for it.
Andy
-----Original Message-----
From: Jason Birch [mailto:Jason.Birch at nanaimo.ca]
Sent: Thursday, March 30, 2006 10:17 AM
To: users at mapguide.osgeo.org
Subject: RE: [mapguide-users] MapAgent parameters
Hey, what do you know...
I tried adding USERNAME=Anonymous to the request and it worked (because
the password is blank). I then tried adding USERNAME=Administrator and
it prompted for authentication. I then tried adding
PASSWORD=mysupersecretpassword to the request and this bypassed
authentication.
I had tried this earlier, but guessed USER instead of USERNAME...
Jason
-----Original Message-----
From: Jason Birch [mailto:Jason.Birch at nanaimo.ca]
Sent: Thursday, March 30, 2006 10:06
To: users at mapguide.osgeo.org
Subject: RE: [mapguide-users] MapAgent parameters
Thanks James,
I had thought about that, but passing authentication info in the link is
so broken (especially in Internet Explorer:
http://support.microsoft.com/kb/834489) that it's not really useful.
This is just a "nice-to-have" until I get to the point of redeveloping
my reports in asp.net or php. I could see it being useful for providing
access to map images on sites that do not have one of the supported
languages installed though.
Jason
-----Original Message-----
From: James Card [mailto:james.card at calcad.com]
Sent: Thursday, March 30, 2006 09:06
To: users at mapguide.osgeo.org
Subject: Re: [mapguide-users] MapAgent parameters
On Wed, 29 Mar 2006 20:44:05 -0800, Jason Birch <Jason.Birch at nanaimo.ca>
wrote:
> It's cool to be able to just call something like this: <URL:
> http://localhost/mapguide/mapagent/mapagent.fcgi?OPERATION=GETMAPIMAGE
> &VERSION=1.0.0&MAPNAME=Sheboygan&LOCALE=en&MAPDEFINITION=Library%3A%2F
> %2FSamples%2FSheboygan%2FMaps%2FSheboygan.MapDefinition&FORMAT=PNG&SET
> VIEWCENTERX=-87.73&SETVIEWCENTERY=43.74&SETVIEWSCALE=5000&SETDISPLAYDP
> I=300&SETDISPLAYWIDTH=3000&SETDISPLAYHEIGHT=2100
> >
>
> It would be nice if I could specify a userid on that line and have the
> agent authenticate using that user with a blank password. I would be
> lazy enough to use this to enhance some existing cold fusion reports.
You can do this by embedding the user credentials in the URL, like this:
<URL:
http://UserID:Password@localhost/mapguide/mapagent/mapagent.fcgi?...
>. However, some browsers block this or prompt the user with a
confirmation dialog before submitting the request to the server, so it
may still not do exactly what you'd hoped for.
--
James Card
California CAD Solutions, Inc.
209 578-5580 Voice
209 521-6493 FAX
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe at mapguide.osgeo.org
For additional commands, e-mail: users-help at mapguide.osgeo.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe at mapguide.osgeo.org
For additional commands, e-mail: users-help at mapguide.osgeo.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe at mapguide.osgeo.org
For additional commands, e-mail: users-help at mapguide.osgeo.org
More information about the Mapguide-users
mailing list