Measurement Widget Not loading in div

1951
5
Jump to solution
09-09-2016 12:08 PM
GeorgeHilton__GISP
New Contributor III

I am having issues loading the Measurement Widget.  I receive errors in the console that indicate that the widget is already loaded. I found past threads on GeoNet concerning using dojoConfig and parser.parse at the same time.  I went through my code and as far as I can see I am only using parser.parse.

I've attached a couple images for reference. The first shows the errors I'm receiving in the console and the second shows the widget loaded without all components.  I've also attached my html and the appropriate js file for reference, however you can work with the application at this location: Town of Queensbury Interactive Mapper 

Any help is appreciated.

George Hilton

Town of Queensbury, NY

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

George,

   The whole issue is the fact that your accordion container is hidden when you are trying to add the measure widget to it. The best workaround for this is to not create the measure widget until the accordian is shown (be sure to remove the other locations of code where you were adding the measure widget before):

        function showhideleg() {
            var legwin = document.getElementById("rightPane");
            //var legwin2 = document.getElementById("rightpane-wrapper");
            // var viz = legwin.style.visibility;
            // var viz2 = legwin2.style.visibility;

            if (ishidden == "TRUE") {
                //console.log(ishidden);
                legwin.style.visibility = "visible";
                registry.byId("accord").selectChild("legendPane", true);
                ishidden = "FALSE";
                if(!measurement){
                  //Create Measurement Widget/Tool
                  measurement = new Measurement({
                      map: map,
                      defaultLengthUnit: "esriFeet"
                  }, "measureDiv");

                  // measurement.on("measure-end", function (evt) {
                  //  clrbuff.disabled = false;
                  //   this.setTool(evt.toolName, false);
                  //});

                  measurement.startup();
                  //End Add Measure Widget/Tool
                }
            } else {
                $("#rightPane").toggle();
            }

            //RESET THIS ONLY IF NEED BE
            //legwin.style.visibility = "visible";
            //registry.byId("accord").selectChild("legendPane", true);
        }

View solution in original post

5 Replies
RickeyFight
MVP Regular Contributor

In your load.js the measurement section is commented out. 

Could you uncomment out the measurement part so we can see the errors from it. 

0 Kudos
GeorgeHilton__GISP
New Contributor III

I'm showing that section uncommented in my working code and through the console.  I apologize if I sent a previous copy of load.js.  Here is the current working code:  load.js

0 Kudos
RickeyFight
MVP Regular Contributor

I see what happened, lower in your load.js, you have more measurement functions that have been commented out. 

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

George,

   The whole issue is the fact that your accordion container is hidden when you are trying to add the measure widget to it. The best workaround for this is to not create the measure widget until the accordian is shown (be sure to remove the other locations of code where you were adding the measure widget before):

        function showhideleg() {
            var legwin = document.getElementById("rightPane");
            //var legwin2 = document.getElementById("rightpane-wrapper");
            // var viz = legwin.style.visibility;
            // var viz2 = legwin2.style.visibility;

            if (ishidden == "TRUE") {
                //console.log(ishidden);
                legwin.style.visibility = "visible";
                registry.byId("accord").selectChild("legendPane", true);
                ishidden = "FALSE";
                if(!measurement){
                  //Create Measurement Widget/Tool
                  measurement = new Measurement({
                      map: map,
                      defaultLengthUnit: "esriFeet"
                  }, "measureDiv");

                  // measurement.on("measure-end", function (evt) {
                  //  clrbuff.disabled = false;
                  //   this.setTool(evt.toolName, false);
                  //});

                  measurement.startup();
                  //End Add Measure Widget/Tool
                }
            } else {
                $("#rightPane").toggle();
            }

            //RESET THIS ONLY IF NEED BE
            //legwin.style.visibility = "visible";
            //registry.byId("accord").selectChild("legendPane", true);
        }
GeorgeHilton__GISP
New Contributor III

Perfect !!! As usual, thank you very much for your assistance !

George

0 Kudos