Hi,
I'm testing "Example 2: Selections" in the "Flexible Web Layout Examples":
Testing the Example2.js provided, a javascript error is generated on the following line:
var oSelection = selection[theMap.getMapName()];
The error generated is:
Fusion Error:
WARNING: Exception occurred in AJAX callback.
Message: getMapName is not a function
The same code appears in
What is the correct code for working with selections?
Kind regards,
Dave.
Solved! Go to Solution.
Oh dear! Someone changed the API and failed to document this!
Anyway, here's how you can get the map name.
//Gets the MapGuide map name from the map widget // //theMap: The Fusion.Widget.Map instance function getMapName(theMap) {
//subMaps will be an array of Fusion.Layers instances (of which Fusion.Layers.MapGuide is a subclass of) var subMaps = theMap.getAllMaps(); for (var i = 0; i < subMaps.length; i++) { if (subMaps[i].arch == "MapGuide") { //Is a Fusion.Layers.MapGuide object return subMaps[i].getMapName(); //Map name is here } } return null; }
Unless you have some strange multi-map setup, the subMaps array will generally have at most one Fusion.Layers.MapGuide instance, so you just find that instance (using the .arch property to determine the correct sub-type) and get the map name from that instance.
- Jackie