fcapellini25 / gmaps-utility-gis

Automatically exported from code.google.com/p/gmaps-utility-gis
0 stars 0 forks source link

legend always uses the legend service even if version is later than 10.01 #20

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. add a layer to the toc widget using code.
2. Load the application
3. Step through TOC.js _RootLayerTOC _getLegendInfo function

What is the expected output? What do you see instead?
Expected to load legend from the layer instead of the arcgis legend tools.

What version of the product are you using? On what operating system?
2.09, Windows 7.

Please provide any additional information below.
I updated the "postCreate" function to make sure the rootLayer is loaded before 
calling the _getLegendInfo function.

Here is the new code that fixes the bug in TOC.js line 620.
-------------------------------------------------------------
         // extenstion point called by framework
         postCreate: function () {
             if ((this.rootLayer instanceof (ArcGISDynamicMapServiceLayer) ||
            this.rootLayer instanceof (ArcGISTiledMapServiceLayer))) {
                 //check if the layer is loaded yet, if not, add a listener to wait
                 if (this.rootLayer.loaded) {
                     if (this._legendResponse) {
                         this._createRootLayerTOC();
                     } else {
                         this._getLegendInfo();
                     }
                 }
                 else {//layer not yet loaded, add listener
                     this.rootLayer.on("load", lang.hitch(this, this._getLegendInfo));
                 }
             } else { //not servicelayer
                 this._createRootLayerTOC();
             }
         },
-----------------------------------

Original issue reported on code.google.com by gref...@gmail.com on 10 Apr 2014 at 8:02

GoogleCodeExporter commented 9 years ago
I was having the same issue.  It appears that this.rootLayer.version is 
returning undefined in _getLegendInfo even though this.rootLayer object was 
returned with the correct version defined in it.

This edit fixed it for me. 

Original comment by travis.b...@gmail.com on 8 May 2014 at 2:22