[fusion-users] Show Layer added in MapScript
Paul Spencer
pspencer at dmsolutions.ca
Thu Mar 11 10:52:36 EST 2010
Hi Tom,
The fusion framework makes a temporary copy of the original map file for use in the current user's session so that it can be manipulated without affecting other users. If you want to change the map file structure in some way, you need to make an ajax call to a server side script and then reload the map on the client side (which you are already doing obviously. The ajax request must include the map name, typically the javascript would look something like this:
myFunction: function() {
var map = Fusion.getMapByIndice(0); // a reference to a mapserver map
var url = 'path/to/my/php/script.php'; // correct URL to your php script
var params = {
mapname: map._sMapname,
session: map.getSessionID(),
myparam: 'some value' // add all the parameters you want to send as key: value pairs
};
var options = {
onSuccess: OpenLayers.Function.bind(map.reloadMap, map),
parameters: params
};
Fusion.ajaxRequest(url, options);
}
you need to be doing something like this on the server side:
<?php
include ("/path/to/fusion/layers/MapServer/php/Common.php");
if (isset($_SESSION['maps']) && isset($_SESSION['maps'][$mapName])) {
$oMap = ms_newMapObj($_SESSION['maps'][$mapName]);
$myparam = $_REQUEST['myparam'];
// your code that manipulates $oMap
$oMap->save($_SESSION['maps'][$mapName]);
}
?>
That's pretty much the simplest way to implement what you need to do I think. Does that make sense?
Cheers
Paul
On 2010-03-11, at 10:18 AM, Tom van der Putte wrote:
> Hi Paul,
>
> I was doing 3), but that's about it. Could you give me some pointers on how to do do 1) and 2)?
>
> Cheers,
> Tom
>
>
>
> On Thu 11/03/10 16:09 , Paul Spencer pspencer at dmsolutions.ca sent:
> are you:
>
> 1) modifying the session copy of the map file
> 2) saving the session copy of the map file after modification
> 3) reloading the map on the client side
>
> Cheers
>
> Paul
>
> On 2010-03-11, at 9:26 AM, Tom van der Putte wrote:
>
> > Hi All,
> >
> > I have a map with several layergroups, and want to make a copy of a user-picked layer in a group by doing an ajax call to a PHP Mapscript. This script executes $oMap->insertLayer($oLayer). This works perfectly in the PHP Mapscript environment ($oMap->getAllLayerNames() shows all layers including the copy). But when the ajax call returns, the layer has not been added to the map. Any ideas why this is?
> >
> > Cheers,
> > Tom
> > _______________________________________________
> > fusion-users mailing list
> > fusion-users at lists.osgeo.org
> > http://lists.osgeo.org/mailman/listinfo/fusion-users
>
>
> __________________________________________
>
> Paul Spencer
> Chief Technology Officer
> DM Solutions Group Inc
> http://research.dmsolutions.ca/
>
>
__________________________________________
Paul Spencer
Chief Technology Officer
DM Solutions Group Inc
http://research.dmsolutions.ca/
More information about the fusion-users
mailing list