[fusion-users] Calling ZoomToSelection

Paul Deschamps pdeschamps at dmsolutions.ca
Sat Sep 27 00:26:43 EDT 2008


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 <mpfister at enplan.com> 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
> mpfister at enplan.com
> 530/221-0440 x108
> 530/221-6963 Fax
>
>
>
> _______________________________________________
> fusion-users mailing list
> fusion-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/fusion-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/fusion-users/attachments/20080927/43745c93/attachment.html


More information about the fusion-users mailing list