Issue with graphics not being visible in multiple graphics layers

3655
5
Jump to solution
06-02-2016 12:25 PM
JonathanKressin
New Contributor III

Hello,

I have a pretty solid JavaScript mapping application that I wrote several years ago.  It is currently using the 3.3 api.  I am moving forward in updating this to 3.16 so that we can get around issues we have been having lately with newer versions of IE.

One big problem I am seeing moving to the latest API is how graphics and graphics layers are being handled.  I have a few different graphics layers for the different functionality in the application.  Adding new graphics to these layers does not produce any errors, but is not displayed.  Looking at the objects behind the scenes, the graphics are being added to the correct layers and everything is flagged as visible.

Trying different APIs, this problem appears to start happening at 3.11.

Does anyone have any ideas on what changed that would affect how graphics are displayed?

Thanks for any advice you can provide!

Sincerely,

Jonathan

(Here is my original app that works correctly at 3.3:  Kenosha County Interactive Mapping )

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Jonathan,

  It's a timing issue. You need to be sure the nap is loaded before trying to add a GraphicsLayer to it:

dojo.connect(kctools.map, "onLoad", function () {
            // Setup Graphics Functionality
            grtool = new kcgis.Graphics(kctools.map, clearTools, kctools.srStateP);
            grtool.showDrawOptions("divDrawOptions");
            grtool.initializeButton("btnDrawPoint", "point");
            grtool.initializeButton("btnDrawLine", "line");
            grtool.initializeButton("btnDrawFreehandLine", "linefree");
            grtool.initializeButton("btnDrawShape", "polygon");
            grtool.initializeButton("btnDrawFreehand", "polyfree");
            //grtool.initializeButton("btnInsertImage", "image");
            grtool.initializeButton("btnInsertText", "text");
            grtool.initializeButton("btnEraseGraphic", "erase");
            grtool.initializeButton("btnClearGraphics", "clearall");
            layerlist.func_image_change = kctools.set_image_base;
            layerlist.initialize(dojo.byId("paneLayers"), kctools.map, master_layer_list, image_layers, kctools.feature_layerlist, kctools.imagebase, "layerlist");


            dojo.connect(kctools.map, "onUpdateEnd", function () { layerlist.onMapUpdate(); });
            dojo.connect(kctools.map, "onUpdateEnd", function () { updateScale(kctools.map.getScale()); });
            //dojo.connect(dojo.byId("chkOrthoToggle"), "onchange", toggleImagery);
            changeImagery("rdoImage2015");
            kctools.map.setScale(12000 * 12);
            //kctools.map.graphics.disableMouseEvents();
        });

View solution in original post

5 Replies
RickeyFight
MVP Regular Contributor

Are you going to try to move to AMD?

0 Kudos
JonathanKressin
New Contributor III

I was really hoping I could stick with the legacy method of defining and consuming modules for now, as I have quite a few custom modules in my code.  I don't have a lot of development time right now to rewrite the program, but was hoping I could at least get it working enough with the latest API to support the latest browsers.

Thanks!

Jonathan

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Jonathan,

  It's a timing issue. You need to be sure the nap is loaded before trying to add a GraphicsLayer to it:

dojo.connect(kctools.map, "onLoad", function () {
            // Setup Graphics Functionality
            grtool = new kcgis.Graphics(kctools.map, clearTools, kctools.srStateP);
            grtool.showDrawOptions("divDrawOptions");
            grtool.initializeButton("btnDrawPoint", "point");
            grtool.initializeButton("btnDrawLine", "line");
            grtool.initializeButton("btnDrawFreehandLine", "linefree");
            grtool.initializeButton("btnDrawShape", "polygon");
            grtool.initializeButton("btnDrawFreehand", "polyfree");
            //grtool.initializeButton("btnInsertImage", "image");
            grtool.initializeButton("btnInsertText", "text");
            grtool.initializeButton("btnEraseGraphic", "erase");
            grtool.initializeButton("btnClearGraphics", "clearall");
            layerlist.func_image_change = kctools.set_image_base;
            layerlist.initialize(dojo.byId("paneLayers"), kctools.map, master_layer_list, image_layers, kctools.feature_layerlist, kctools.imagebase, "layerlist");


            dojo.connect(kctools.map, "onUpdateEnd", function () { layerlist.onMapUpdate(); });
            dojo.connect(kctools.map, "onUpdateEnd", function () { updateScale(kctools.map.getScale()); });
            //dojo.connect(dojo.byId("chkOrthoToggle"), "onchange", toggleImagery);
            changeImagery("rdoImage2015");
            kctools.map.setScale(12000 * 12);
            //kctools.map.graphics.disableMouseEvents();
        });
JonathanKressin
New Contributor III

That did the trick!  Thank you for your help!

Jonathan

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Jonathan,


  Be sure to close this thread out by marking it as answered. To do that click on the "Correct Answer" link on the reply that answered your question.

0 Kudos