Infrastructure Map Server Developer

Infrastructure Map Server Developer

Active Member
Posts: 9
Registered: ‎08-29-2005
Message 1 of 2 (465 Views)

AIMS Fusion Dev Examples not working at all, and not updated since version 2012

465 Views, 1 Replies
09-06-2013 11:11 AM



I realized that there is still the same problem with Fusion Dev’s Guide Example 2 in AIMS 2013 and 2014 as you can read from either




In the past some months ago I’d asked Daniel Du the reason why this is not working, and he sent me a workaround but I realize that there are some drawbacks as I explain below.


Example 2 fails since there is an error when we are trying to invoke getMapName method due to there isn't a getMapName method in Map.js used by the MapWidget, therefore Daniel’s approach was to add the method to Map.js

C:\Program Files\Autodesk\Autodesk Infrastructure Web Server Extension <2013|2014> \www\fusion\lib\Map.js:


   //Added by Daniel 2012/11/01

       getMapName: function() {

              return this.aMaps[0]._sMapname;



Digging some other posts this code also works:


     getMapName: function () {

        for (var i = 0; i < this.aMaps.length; i++) {

            var aMap = this.aMaps[i];

            if (aMap.layerType == "MapGuide") {

                return aMap._sMapname;               




At this point I can't see the reason why the main map is in such layer named "MapGuide" or if the  main Map is always the first element (aMaps[0]) in the aMaps array from the MapWidget. Could you tell me which code is likely to work in all AIMS current versions?.


Secondly this implies editing the index.html file from the template where using in our Flexible Web Layout, changing the following line, for the second one:


<script type="text/javascript" src="../../../lib/fusionSF-compressed.js"></script>


Now it should be:


<script type="text/javascript" src="../../../lib/fusion.js"></script>


Otherwise our edited version of Map.js won't be loaded , I guess that fusionSF-compressed.js was generated with some tool like uglify.js that parses and compress a set of JS files into just one.


I realized that if we are trying to fix the Example 2, we could better implement the function within the JS as follows instead of modifying Map.js and changing the index.html file as follows:



var theMap = Fusion.getWidgetById("Map");
if (!theMap.hasSelection())
  alert("Nothing selected");
var oSelection = selection[this.getMapName()];

var thisLayer = oSelection.getLayerByName('Parcels');

for (var layerNum = 0; layerNum < oSelection.getNumLayers();
  var thisLayer = oSelection.getLayer(layerNum);
  var selectedFeaturesThisLayer = thisLayer.getNumElements();
  if (selectedFeaturesThisLayer > 0)
    // Process the selected features

getMapName: function()
        var map = this.getMap();
        for(var i = 0; i<map.aMaps.length;i++){
            var aMap = map.aMaps[i];
                return aMap.getMapName();
        return '';


I want to know if this approach is good enough in order to still use fusionSF-compressed.js and the fusion templates out-the-box.


Also I have see a lot of one-year-old posts with Fusion samples like this, that reffers to put this code line in JS:



        // set isFusion to false if you are using Ajax viewer
        var isFusion = true;

function RefreshMap() {
            if (isFusion) {                
                Fusion =;

                //reload the Map to refresh legend
            else {              

                // if using basic weblayout, referenceing 
                // to MapGuideViewerApi.js should be removed





But in some scenarios involving Custom Widgets or Invoke URL Widget doesn't work, by digging in some other posts they remove this line of code:


Fusion =;



Why is that?, also I realized that I was also removed from MapGuide/MapGuideViewerApi.js functions as follows:


function Refresh() {
    //var Fusion =;
    var mapWidget = Fusion.getWidgetById(mgApiMapWidgetId);
    if (mapWidget && mapWidget.isMapLoaded()) {

function SetSelectionXML(selectionXml) {
    //var Fusion =;
    var mapWidget = Fusion.getWidgetById(mgApiMapWidgetId);
    if (mapWidget && mapWidget.isMapLoaded()) {
        mapWidget.setSelection(selectionXml, true);



Finaly regarding Example 3 it wasn't working in AIMS 2013, I don't know if someone have tried this on AIMS 2014.




Francisco Rojas



Board Manager
Posts: 203
Registered: ‎12-23-2008
Message 2 of 2 (315 Views)

Re: AIMS Fusion Dev Examples not working at all, and not updated since version 2

02-16-2014 06:56 PM in reply to: francisco.rojas



First question: 

Fusion is based on OpenLayers, and the concept of 'layer' in OpenLayers and in MapGuide or AIMS are differenct, as OpenLayers can contains 'mapguide' layer , as well as other layer types, such as google map layers, wms layers ,etc. so 'mapguide' layer in OpenLayers actually is a 'map' in mapguide. 


So following code snippet is better.


 getMapName: function () {

        for (var i = 0; i < this.aMaps.length; i++) {

            var aMap = this.aMaps[i];

            if (aMap.layerType == "MapGuide") {

                return aMap._sMapname;               





Second one: 

As the name implies, fusionSF-compressed.js means compressed single file of fusion libarary. Javascript compressed the different javascript files into single file and compress them by removing comments/spaces etc to improve performace. But for debuging, we need to use the origenal version,  that's why we need to change like this: 

<script type="text/javascript" src="../../../lib/fusion.js"></script>



But of cause, you can do the compression process to generate the fusionSF-compressed.js after you did some modification. Many tools can be used to do this.



Thrid one: 

The code to get Fusion object depens how you use fusion viewer. As the sample demoed, fusion is used in one of built-in templates, it is something like;

But if you open the fusion viewer in nother window, it may be 


Or if you embed fusion into an iframe tag, it will be a different way. anyway, it really depends how you use it, and it depend some javascript knowledget. 


Hope this clarifies. 


Daniel Du
Developer Technical Services
Autodesk Developer Network

Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.