[fusion-users] How to pass a parameter from URL
Paul Deschamps
pdeschamps at dmsolutions.ca
Wed Feb 18 09:19:26 EST 2009
Hi jsanchez,
There are a few different ways you can accomplish this. I would recommend
that you create a separate php script and call it on the fusion.onInitialize
Here's some sample code. It may be a little rough and need a little TLC as I
just whipped it together for you.
window.onload = function() {
Fusion.initialize();
Fusion.registerForEvent(Fusion.Event.FUSION_INITIALIZED, onInitialize);
}
function onInitialize(){
// create a queryString object
var oQS = new queryString();
// get the QS "layers"
var gLayers = oQS.get("layers");
// get the mapwidget
var mapWidget = Fusion.getMapById('mapArea');
var maps = mapWidget.getAllMaps();
var map = maps[0];
// set the parameters for sessionid and mapname and layers
var session = 'session='+map.getSessionID();
var mapName = '&mapname='+ map._sMapname;
var layers = '&layers='+gLayers;
var params = session+mapName
// bind ajax call to the function reloadMap
var opts = {parameters: params, onComplete: reloadMap.bind(null)};
var s = "../myApp/showLayers.php";
// trigger the ajax call
Fusion.ajaxRequest(s, opts);
}
function reloadMap(){
var map = Fusion.getMapById('mapArea');
var maps = map.getAllMaps();
maps[0].reloadMap();
}
function queryString(qs){
d.log("queryString");
this.params = {};
this.get=queryString_get;
if (qs == null)
qs=location.search.substring(1,location.search.length);
if (qs.length == 0) return;
qs = qs.replace(/\+/g, ' ');
var args = qs.split('&');
// split out each name=value pair
for (var i=0;i<args.length;i++) {
var value;
var pair = args[i].split('=');
var name = unescape(pair[0]);
if (pair.length == 2)
value = unescape(pair[1]);
else
value = name;
this.params[name] = value;
}
}
/*
function queryString_get - return the key values
*/
function queryString_get(key, default_) {
// This silly looking line changes UNDEFINED to NULL
if (default_ == null) default_ = null;
var value=this.params[key];
if (value==null) value=default_;
return value;
}
On Wed, Feb 18, 2009 at 5:18 AM, jsanchez <ebarrera at inm.es> wrote:
>
>
> Hello all,
>
> I'm just testing 'Fusion' and I wonder if it would be possible to deal with
> dynamic layers.
>
> I would like the user could choose the data shown in a fixed given layer.
> To
> do so, I don't define the layer it on my MapServer/MAPFILE but instead I
> create it during Fusion load proccess using Mapscript in LoadMap.php which
> works fine.
>
> Now I'd like to know how to pass a parameter from URL application to
> LoadMap.php containing the 'data' layer parameter which points to desired
> raster file.
>
>
> Thanks
>
>
> --
> View this message in context:
> http://n2.nabble.com/How-to-pass-a-parameter-from-URL-tp2346032p2346032.html
> Sent from the Fusion Users mailing list archive at Nabble.com.
>
> _______________________________________________
> fusion-users mailing list
> fusion-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/fusion-users
>
--
Paul Deschamps
Applications Specialist
DM Solutions Group Inc.
Office: (613) 565-5056 x28
pdeschamps at dmsolutions.ca
http://www.dmsolutions.ca
http://research.dmsolutions.ca
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/fusion-users/attachments/20090218/77f669c9/attachment.html
More information about the fusion-users
mailing list