Calling ZoomToSelection

2 messages Options
Embed this post
Permalink
Marc Pfister

Calling ZoomToSelection

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)

So how do I execute one widget from another one? I want the MapServer search widget to zoom to the selection by calling the ZoomToSelection widget. Is there a way to trigger a widget in Fusion similar to activating one with activateWidget? Otherwise, what is the appropriate  JS syntax?

 

Fusion.Widget.ZoomToSelection.prototype.execute() at least gets me to the ZoomToSelection function, but then I get an error about this.GetMap() so I must be blowing it in the function scope.

 

n
Marc Pfister
Geospatial Data Manager
ENPLAN
[hidden email]
530/221-0440 x108
530/221-6963 Fax

 


_______________________________________________
fusion-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fusion-users
Paul Deschamps

Re: Calling ZoomToSelection

Reply Threaded More More options
Print post
Permalink
opps forgot to add this to the list :)

You just need to create a couple of functions and a event register for the selection:

function onInitialize() {
var map = Fusion.getMapById('mapwindow');
map.registerForEvent(Fusion.Event.MAP_SELECTION_ON, selectionOn);


}

// event watcher.
function selectionOn() {
var mapWidget = Fusion.getMapById('mapwindow');
var maps = mapWidget.getAllMaps();
var map = maps[0];

// get the selection and trigger selectionLoaded with the obj

map.getSelection(selectionLoaded.bind(null));
}

// selection loaded now zoom to the extents
function selectionLoaded(obj){
var a = [];

a[0] = parseFloat(obj.fMinX);
a[1] = parseFloat(obj.fMinY);

a[2] = parseFloat(obj.fMaxX);
a[3] = parseFloat(obj.fMaxY);

var mapWidget = Fusion.getMapById('mapwindow');
var maps = mapWidget.getAllMaps();
var map = maps[0];

map.mapWidget.setExtents(new OpenLayers.Bounds(a[0], a[1], a[2], a[3]));

}
You will notice that in the selectionLoaded Func this object will return the extents of the selection, Now in this function you need to just trigger a "zoomToExtents" function with the extents


Hope this helps

Cheers

Paul D.

On Fri, Sep 26, 2008 at 6:49 PM, Marc Pfister <[hidden email]> wrote:

So how do I execute one widget from another one? I want the MapServer search widget to zoom to the selection by calling the ZoomToSelection widget. Is there a way to trigger a widget in Fusion similar to activating one with activateWidget? Otherwise, what is the appropriate  JS syntax?

 

Fusion.Widget.ZoomToSelection.prototype.execute() at least gets me to the ZoomToSelection function, but then I get an error about this.GetMap() so I must be blowing it in the function scope.

 

n
Marc Pfister
Geospatial Data Manager
ENPLAN
[hidden email]
530/221-0440 x108
530/221-6963 Fax

 


_______________________________________________
fusion-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fusion-users



_______________________________________________
fusion-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fusion-users