[mapguide-users] Fusion Selection Handler

Greg gbneff at cid.utah.gov
Tue Jun 25 14:17:11 PDT 2013


Mapguide 2.5 64 bit
Windows 7 64 bit
fusion viewer

I trying to write a simple selection handler and am struggling with the
Fusion.SelectionObject.  In the following code I can capture the selection
and get the layers of the selected entities.  I don't know why, however,
selection.getNumElements() always returns 0 regardless of the number
selected.  The code is in my index.html file.  Any ideas?

var fusionInitialized = function () {
    $('AppContainer').resize({ forceResize: true });
    mapWidget = Fusion.getMapById('Map');
    mapWidget.registerForEvent(Fusion.Event.MAP_LOADED, initPanelHandler);

    mapWidget.registerForEvent(Fusion.Event.MAP_SELECTION_ON, selectionOn);
}

function selectionOn() {
    maps = mapWidget.getAllMaps();
    for (var i = 0; i < maps.length; i++) {
        if (maps[i].arch == "MapGuide") {
            maps[i].getSelection(displaySelection);
        }
    }
}

function displaySelection(selection) {
    alert("Number selected is: " + selection.getNumElements()); //always
returns 0
    alert("Number layers selected: " + selection.getNumLayers()); //returns
correct # of layers
    if (selection && selection.getNumElements() == 1) {
        var selLayer = selection.getLayer(0);
        var selLayerName = selLayer.name();
        alert("Layer = " + selLayerName);
    }
}



--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Fusion-Selection-Handler-tp5062180.html
Sent from the MapGuide Users mailing list archive at Nabble.com.


More information about the mapguide-users mailing list