Infowindow and editor window conflicting?

6984
9
02-08-2015 08:24 PM
EdwardSohn2
New Contributor III

Following is snippet of code that initializes editor window for set of editable feature layers.

However when those layer features are clicked, the regular infowindow (not edit window) comes up.

The regular infowindow should operate for other layers that are on the map, but the editor window for the layers that are specified in the code below.  Is the infowindow conflicting with the editor window, or can they coexist somehow?  The editor window is not coming up when clicking on the features for the layers below... the regular infowindow comes up.

  require([

                    "esri/dijit/editing/Editor", "esri/dijit/editing/TemplatePicker"

                    ], lang.hitch(this, function (

                        Editor, TemplatePicker) {

                        var featureLayers = [];

                        this._incidentsLayers.forEach(function (l) {

                            featureLayers.push(l);

                        });

                        var templatePicker = new TemplatePicker({

                            featureLayers: featureLayers,

                            grouping: false,

                            rows: 1,

                            columns: "auto"

                        }, "editorDiv");

                        templatePicker.startup();

                      

                        var layerInfos = [];

                        this._incidentsLayers.forEach(function (l) {

                            featureLayers.push({ "featureLayer": l });

                        });

                        var settings = {

                            map: this.map,

                            templatePicker: templatePicker,

                            layerInfos: layerInfos

                        };

                        var params = { settings: settings };

                        var editorWidget = new Editor(params);

                        editorWidget.startup();

                        deferred.resolve(true);

                    }));

0 Kudos
9 Replies
ChrisSergent
Regular Contributor III

I had the same issue when I was trying to add an editor widget and the geocode widget. Sometimes an infoWindow would display when I tried to use the editor widget. Here is a sample of how the conflict was removed: Adding an Editor to the Template Check out the blocks of code for destroying the editor and and creating the editor and the block of code for showLocation  The showLocation function destroys the editor and re-creates it. This allows for the infoWindow and the editor to co-exist without issue.

0 Kudos
EdwardSohn2
New Contributor III

The editor window just doesn't show up whenever clicking on a feature.  Only the regular infowindow shows up.  What needs to be done to trigger the editor window to show up...

0 Kudos
ChrisSergent
Regular Contributor III

Can you post the code for the entire page?

by Anonymous User
Not applicable

I just solved this.  In my opinion ESRI should look in making this just work out of the box.

The following threads have seemed to solve this but I haven't seen many people post an entire working page.

identify dynamicservice layers and edit feature layer

Setting InfoWindow content disables Editor Widget attributes display

Default editor and conflicting infoWindows with featureLayers

etc...


I will post a complete working example you can just copy and paste into the ESRI Sandbox, that works. ArcGIS API for JavaScript Sandbox  It works completely, using sample ESRI services. Most importantly, it works with the AGS TOC Widget. And only identifies visible layers.

Then I will post a second sample where I integrated it into our main viewer, with Measurement, Pictometry and some other common widgets. Feel free to use it. Sorry I can't post most of the service URLs so you will have to go through and put yours in. Note that we use a file of URLs and so getWebData.whateverLayername such as getWebData.Imagery2011 refers to just a URL string, with the getWebData object holding all the URLs for our site. Paste your REST links directly over this instead, or follow this pattern, which cleans up the javascript map file nicely.

EXAMPLE 1:

////////////////

<!DOCTYPE html>

<html>

<head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">

    <title>Identify and Editor </title>

    <link rel="stylesheet" href="http://js.arcgis.com/3.12/dijit/themes/claro/claro.css">

    <link rel="stylesheet" type="text/css" href="http://js.arcgis.com/3.12/esri/css/esri.css">

  

    <script type="text/javascript">

    var dojoConfig = {   //3.12 vers

        async: false,

        parseOnLoad: true,

        packages: [{

            "name": "agsjs",

            "location": 'http://gmaps-utility-gis.googlecode.com/svn/tags/agsjs/2.10/build/agsjs/dijit/' // for xdomain load

        }]

    };

        </script>

    <script type='text/javascript' src="http://js.arcgis.com/3.12/"></script>

  

    <style type='text/css'>

        html, body, #divMap {

            height: 100%;

            width: 100%;

            margin: 0;

            padding: 0;

        }

        body {

            background-color: #FFF;

            overflow: hidden;

            font-family: "Trebuchet MS";

        }

        #bcMain {

            width: 100%;

            height: 100%;

        }

        #cpTop {

            height: 50px;

        }

        #cpLeft {

            width: 215px;

            overflow: hidden;

        }

    </style>

    <script type='text/javascript'>

//<![CDATA[

        window.onload = function () {

            var map, widgetEditor, functionMode;

            require([

                "esri/map",

                "esri/layers/ArcGISDynamicMapServiceLayer",

                "esri/layers/FeatureLayer",

                "esri/tasks/GeometryService",

                "esri/dijit/editing/Editor",

                "esri/dijit/editing/TemplatePicker",

                "esri/config",

                "esri/tasks/IdentifyTask",

                "esri/tasks/IdentifyParameters",

                "esri/InfoTemplate",

                    "dojo/dom-construct",

                        "dojo/dom-style",

                            "esri/dijit/Legend",

                   "dojo/_base/Color",

                    "esri/geometry/Extent",

                                 "esri/layers/ArcGISTiledMapServiceLayer",

             "esri/symbols/SimpleFillSymbol",

             "esri/renderers/ClassBreaksRenderer",

"dojo/_base/fx",

"agsjs/TOC",

                "dojo/ready",

                "dojo/parser",

                "dojo/dom",

                "dojo/on",

                "dojo/_base/array",

                "dijit/layout/BorderContainer",

                "dijit/layout/ContentPane",

            ],

            function (

                Map, ArcGISDynamicMapServiceLayer, FeatureLayer, GeometryService, Editor, TemplatePicker, config,

                IdentifyTask, IdentifyParameters, InfoTemplate, domConstruct, domStyle, Legend,

                                     Color,

                                                          Extent,

          ArcGISTiledMapServiceLayer,

             SimpleFillSymbol,

             ClassBreaksRenderer,

             baseFx,

                TOC,

                ready, parser, dom, on, arrayUtils,

                BorderContainer, ContentPane) {

                ready(function () {

                    parser.parse();

                    //config.defaults.io.proxyUrl = "http://localhost/proxy/proxy.ashx";

                    map = new Map("divMap", {

                        basemap: "topo",

                        center: [-109.86, 40.3],

                        zoom: 14

                    });

                    var flFirePoints,  webmap;

                    webmap = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Energy/Infrastructure/MapServer";

                    var webmapLayer = new esri.layers.ArcGISDynamicMapServiceLayer(webmap, {

                        id: 'Dynamic'

                    }

                    );

      

                    flFirePoints = new FeatureLayer("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/0", {

                        mode: FeatureLayer.MODE_ONDEMAND,

                        outFields: ["*"]

                    });

                    map.addLayers([flFirePoints, webmapLayer]);

                    dojo.connect(map, 'onLayersAddResult', function() {

                        var KSAVLayers = new agsjs.dijit.TOC({

                            map: map,

                            collapsed: false,

                            layerInfos: [

                                {

                                    layer: webmapLayer,

                                    slider: false,

                                    title: "Web Map Layers"

                                }

                            ]

                        }, 'TocDiv');

                        KSAVLayers.startup();

                    });

                    on(dom.byId("startEditing"), "click", initEditor);

                    on(dom.byId("stopEditing"), "click", stopEditing);

                    functionMode = true;

                    on(map, "click", function(evt) {

                        if (functionMode == true) {

                            executeIdentifyTask(evt);

                        } else {

                            return;

                        }

                    });

                    identifyTask = new IdentifyTask(webmap);

                    identifyParams = new IdentifyParameters();

                    identifyParams.tolerance = 3;

                    identifyParams.returnGeometry = true;

                    identifyParams.layerIds = webmapLayer.visibleLayers;

                    identifyParams.layerOption = IdentifyParameters.LAYER_OPTION_ALL;

                    identifyParams.width = map.width;

                    identifyParams.height = map.height;

                    function executeIdentifyTask(evt) {

                        identifyParams.geometry = evt.mapPoint;

                        identifyParams.mapExtent = map.extent;

                        identifyParams.layerIds = webmapLayer.visibleLayers;

                        var deferred = identifyTask.execute(identifyParams);

                        deferred.addCallback(function (response) {

                            return dojo.map(response, function (result) {

                                var feature = result.feature;

                                feature.attributes.layerName = result.layerName;

                                var template = new InfoTemplate("", "${*}");

                                feature.setInfoTemplate(template);

                    template.setTitle(result.layerName);

                                return feature;

                            });

                        });

                        map.infoWindow.setFeatures([deferred]);

                        map.infoWindow.show(evt.mapPoint);

                    }

                

                    function initEditor() {

                        map.graphics.clear();

                        functionMode = false;

                        templatePicker = new TemplatePicker({

                            featureLayers: [flFirePoints]

                        }, "divLeft");

                        templatePicker.startup();

                        var layers = [{ featureLayer: flFirePoints }];

                        var settings = {

                            templatePicker: templatePicker,

                            map: map,

                            layerInfos: layers,

                            toolbarVisible: true,

                            createOptions: { polygonDrawTools: [esri.dijit.editing.Editor.CREATE_TOOL_FREEHAND_POLYGON] }

                        };

                        var params = {

                            settings: settings

                        };

                        myEditor = new Editor(params, 'topDiv');

                        myEditor.startup();

                    };

                    function stopEditing() {

                        templatePicker.destroy();

                        myEditor.destroy();

                        dojo.create("div", {

                            id: "divLeft"

                        }, "cpLeft");

                        dojo.create("div", {

                            id: "topDiv"

                        }, "cpTop");

                        functionMode = true;

                    }

                });

            });

        }//]]>

    </script>

</head>

    <body class="claro">

        <div id="bcMain" data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="design:'sidebar'">

            <div id="cpTop" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'top'">

                <div id="divTop"></div>

                <input type="button" id="startEditing" value="Start Editing" />

                <input type="button" id="stopEditing" value="Stop Editing" />

            </div>

            <div id="cpLeft" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'left'">

                <div id="divLeft" style="z-index: 44;">

                </div>

                <div id="TocDiv" style="position: absolute; top: 380px; z-index: 99;"></div>

                <div id="topDiv"></div>

            </div>

            <div id="cpCenter" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'center'">

                <div id="divMap"></div>

            </div>

        </div>

</body>

</html>

by Anonymous User
Not applicable

///example 2//fullproject///

/// I can't live link to this site, it's an internal intranet site.

/////JS file ... I know it's ugly.... had to get done fast, will come back and clean it up someday and perhaps post cleaner copy...

require([

    "dojo/dom",

    "dojo/dom-style",

    "dojo/on",

    "esri/InfoTemplate",

    "esri/tasks/IdentifyTask",

    "esri/tasks/IdentifyParameters",

    "esri/dijit/Popup",

    "esri/layers/FeatureLayer",

    "esri/tasks/query",

    "esri/dijit/Geocoder",

    "esri/geometry/Extent",

    "esri/dijit/Legend",

    "esri/dijit/Print",

    "agsjs/TOC",

                    "dojo/ready",///////////

    "dojo/DeferredList",

    "dojo/_base/connect",

    "esri/layers/ArcGISTiledMapServiceLayer",

    "esri/layers/ArcGISDynamicMapServiceLayer",

    "esri/layers/ArcGISImageServiceLayer",

    "esri/layers/ImageServiceParameters",

    "dojo/dom-construct",

    "esri/dijit/OverviewMap",

    "esri/undoManager",

    "esri/dijit/editing/TemplatePicker",

    "esri/dijit/editing/Editor",

    "dojo/dom-style",

    "dojo/_base/array",

    "esri/Color",

    "dojo/keys",

    "dojo/parser",

    "esri/config",

    "esri/sniff",

    "esri/map",

    "esri/SnappingManager",

    "esri/dijit/Measurement",

    "esri/layers/FeatureLayer",

    "esri/renderers/SimpleRenderer",

    "esri/tasks/GeometryService",

    "esri/symbols/SimpleLineSymbol",

    "esri/symbols/SimpleFillSymbol",

    "esri/renderers/ClassBreaksRenderer",

    "esri/dijit/Scalebar",

    "dojo/_base/fx",

    "dijit/layout/BorderContainer",

    "dijit/layout/ContentPane",

    "dijit/TitlePane",

    "dijit/form/CheckBox",

    "dojo/domReady!"

], function(

    dom,

    domStyle,

    on,

    InfoTemplate,

    IdentifyTask,

    IdentifyParameters,

    Popup,

    FeatureLayer,

    Query,

    Geocoder,

    Extent,

    Legend, Print,

    TOC,

    ready,

    DeferredList, connect,

    ArcGISTiledMapServiceLayer, ArcGISDynamicMapServiceLayer, ArcGISImageServiceLayer, ImageServiceParameters,

    domConstruct, OverviewMap, UndoManager, TemplatePicker, Editor,

    domStyle, arrayUtils,

    Color, keys, parser,

    esriConfig, has, Map, SnappingManager, Measurement, FeatureLayer, SimpleRenderer, GeometryService, SimpleLineSymbol, SimpleFillSymbol,

    ClassBreaksRenderer, Scalebar, baseFx

) {

    ready(function () {

        parser.parse();

        esriConfig.defaults.geometryService = new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");

        var eventHandlerIdentify,

            executeIdentifyTask,

            Pict,

            DivTest,

            functionMode,

            handlerPictometry,

            IdentifyActive,

            identifyTask,

            identifyParams,

            myEditor,

            measureMode;

        // popup and infoTemplate    

        var popup = new Popup({

            fillSymbol: new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,

                new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,

                    new dojo.Color([255, 0, 0, 0]), 2), new dojo.Color([255, 255, 0, 0.25]))

        }, dojo.create("div"));

        // create the map: Note that loading the basemap using the esri basemap property doesn't seem to set the WKID correctly,

        //   explicit loading seems to work as expected.

        map = new esri.Map("map", {

            slider: true,

            wrapAround180: false, //set wraparound to false if the extent is limited.

            showAttribution: false,

            logo: false,

            infoWindow: popup,

            autoResize: true,

           //basemap: "topo",

            center: [-81.05775, 32.1],

            zoom: 11

        });

        var basemap = new esri.layers.ArcGISTiledMapServiceLayer(getWebData.Imagery2011);

        map.addLayer(basemap); // added first to ensure the spatial reference is set right

        //dojo.place(popup.domNode, map.root);  // puts the popup in the map space

        ////// UN-COMMENT THESE PROXY LINES BELOW WHEN DEPLOYING

  //      esri.config.defaults.io.proxyUrl = "/proxy.ashx";

//       esri.config.defaults.io.alwaysUseProxy = true;

        ///// Layers

        // loading indicator

        dojo.connect(map, "onUpdateStart", function () {

            esri.show(dojo.byId("status"));

        });

        dojo.connect(map, "onUpdateEnd", function () {

            esri.hide(dojo.byId("status"));

        });

        //additional ESRI basemaps

        var basemapESRIimagery = new esri.layers.ArcGISTiledMapServiceLayer(getWebData.ESRIWorldImagery);

        var basemapESRIstreetmap = new esri.layers.ArcGISTiledMapServiceLayer(getWebData.ESRIWorldStreetMap);

        var basemapESRIblackandwhite = new esri.layers.ArcGISTiledMapServiceLayer(getWebData.ESRIWorldBlackWhite);

        var basemap2 = new esri.layers.ArcGISTiledMapServiceLayer(getWebData.ESRIWorldTopoMap);

        //imagery

        basemapESRIblackandwhite.hide();

        //basemapESRIstreetmap.hide();

        basemapESRIimagery.hide();

        basemap.hide();

        basemap2.hide();

        //var KSAVDynamicLayersALL = new esri.layers.ArcGISDynamicMapServiceLayer(getWebData.KSAVall, {

        //    id: 'Dynamic'

        //}

        //);

        //var pointsOfInterest = new esri.layers.FeatureLayer(getWebData.CNTlayers, {

        //    mode: esri.layers.FeatureLayer.MODE_ONDEMAND, //QUERY_SELECTION is working as well

        //    outFields: ['*']

        //});

        //map.addLayers([pointsOfInterest]);

        //var basemap = new esri.layers.ArcGISTiledMapServiceLayer(getWebData.Imagery2011);

        //map.addLayer(basemap); // added first to ensure the spatial reference is set right

        ////config.defaults.io.proxyUrl = "http://localhost/proxy/proxy.ashx";

        var flFirePoints, webmap, webmapAnno;

        webmapAnno = "Layer1url/MapServer";

        webmap = "Layer2url/MapServer";

        var webmapLayer = new esri.layers.ArcGISDynamicMapServiceLayer(webmap, {

            id: 'Dynamic'

        }

        );

        var webmapLayerAnno = new esri.layers.ArcGISDynamicMapServiceLayer(webmapAnno, {

            id: 'DynamicAnno'

        }

       );

        //  webmapLayer.setVisibleLayers([]);

        // webmapLayer.setVisibleLayers([45, 46]);

        flFirePoints = new FeatureLayer("Layer3editURL/FeatureServer/0", {

            mode: FeatureLayer.MODE_ONDEMAND,

            outFields: ["*"]

        });

        map.addLayers([flFirePoints]);

        webmapLayer.setVisibleLayers([0]);

        webmapLayer.setVisibleLayers([]);

        webmapLayer.hide();

        // set up the KSAV TOC widget

        dojo.connect(map, 'onLayersAddResult', function () {

    var Basemaps = new agsjs.dijit.TOC({

                map: map,

                layerInfos: [

                    {

                      

                        layer: basemap2,

                        title: "ESRI Topographic Basemap",

                        slider: true

                    }, {

                        layer: basemapESRIblackandwhite,

                        title: "ESRI Grayscale",

                        slider: true

                    }, {

                        layer: basemapESRIstreetmap,

                        title: "ESRI Streetmap",

                        slider: true

                    }, {

                        layer: basemapESRIimagery,

                        title: "ESRI Imagery",

                        slider: true

                   }

                ]

            }, 'BasemapsDiv');

                var KSAVLayers = new agsjs.dijit.TOC({

                    map: map,

                    collapsed: false,

                    layerInfos: [

                        {

                            layer: webmapLayer,

                            slider: true,

                            title: "Map Layers"

                        },

                          {

                              layer: webmapLayerAnno,

                              slider: false,

                              title: "Street Name Labels"

                              }

                    ]

                }, 'operationalLayers');

                var CNTlayers = new agsjs.dijit.TOC({

                    map: map,

                    collapsed: false,

                    layerInfos: [

                        {

                            layer: flFirePoints,

                            slider: false,

                            title: "CNT Points"

                        }

                    ]

                }, 'CNTpointsTOC');

                Basemaps.startup();

                CNTlayers.startup();

                KSAVLayers.startup();

        });

        ///////////Identify Widget//////

    functionMode = true;

    on(map, "click", function (evt) {

       

            if (functionMode == true) {

                executeIdentifyTask(evt);

            } else {

                return;

            }

    });

        identifyTask = new IdentifyTask(webmap);

        identifyParams = new IdentifyParameters();

        identifyParams.tolerance = 3;

        identifyParams.returnGeometry = true;

        identifyParams.spatialReference = map.spatialReference;

        identifyParams.layerIds = webmapLayer.visibleLayers;

        identifyParams.layerOption = IdentifyParameters.LAYER_OPTION_ALL;

        identifyParams.width = map.width;

        identifyParams.height = map.height;

        function executeIdentifyTask(evt) {

            measureMode = dojo.query(".esriButton .dijitButtonNode").some(function (node, index, arr) {

                if (node.childNodes[0].checked) {

                    //at least one of the measure tools is active so disable identify

                    return true;

                }

            });

            if (!measureMode) {

                if (Pict == false) {

            identifyParams.geometry = evt.mapPoint;

            identifyParams.mapExtent = map.extent;

            identifyParams.layerIds = webmapLayer.visibleLayers;

            identifyParams.spatialReference = map.spatialReference;

            var deferred = identifyTask.execute(identifyParams);

                    var titleLayer;

            deferred.addCallback(function (response) {

                return dojo.map(response, function (result) {

                    var feature = result.feature;

                    feature.geometry.spatialReference = map.spatialReference;

                    feature.attributes.layerName = result.layerName;

                    titleLayer = result.layerName;

                    //var template = new InfoTemplate(result.layerName, "${*}");

                    //feature.setInfoTemplate(template);

                    var contentString = "";

                    var sp = new Array();

                    sp = feature.attributes;

                //    contentString += "<b>" + result.layerName + "</b><hr width = '90%'>";

                    for (x in sp) {

                        if (x != "OBJECTID" && x != "SHAPE.len" && x != "GlobalID" && x != "SHAPE_LENG" && x != "layerName" && x != "Shape.len" && x != "Shape.area" && x != "SHAPE.area" && x != "Shape.STArea()" && x != "Shape.STLength()" && x != "SHAPE" && x != "Shape" && x != "weblink" && x != "weblink2" && x != "DocumentLink" && x != "VideoLink") {

                            contentString += "<i>" + x + "</i>: " + feature.attributes + "<br/>";

                        }

                    }

                    var infoTemplate = new esri.InfoTemplate();

                 //   infoTemplate.setTitle("Details");

                    infoTemplate.setContent(contentString);

                    map.infoWindow.resize(360, 410);

                    var data = {

                        identifier: "OBJECTID",

                        label: "ID",

                        items: sp

                    };

                    feature.setInfoTemplate(infoTemplate);

                    infoTemplate.setTitle(result.layerName);

                    return feature;

                });

            });

            map.infoWindow.setFeatures([deferred]);

            map.infoWindow.show(evt.mapPoint);

       //     map.setMapCursor("default");

                }; // end Pict if

                }; // end measureMode if

            }

        /// add layers with imagery and esri basemaps AFTER identify so they don'try appear in identify results

        map.addLayers([

            basemapESRIimagery,

            basemapESRIstreetmap,

            basemapESRIblackandwhite,

            basemap2,

          webmapLayer,

    webmapLayerAnno

            //KSAVDynamicLayersALL,

            //pointsOfInterest

        ]);

        webmapLayer.setVisibleLayers([0]);

        webmapLayer.setVisibleLayers([]);

        webmapLayer.hide();

        webmapLayerAnno.setVisibleLayers([0]);

        webmapLayerAnno.setVisibleLayers([]);

        webmapLayerAnno.hide();

        //KSAVDynamicLayersALL.setVisibleLayers([0]);

        //KSAVDynamicLayersALL.setVisibleLayers([]);

        //KSAVDynamicLayersALL.hide();

        function initEditor() {

         map.graphics.clear();

            functionMode = false;

            templatePicker = new TemplatePicker({

                featureLayers: [flFirePoints],

                rows: 'auto',

                columns: 1

            }, "dialogeditor");

            templatePicker.startup();

            var layers = [

                {

                    'featureLayer':flFirePoints,

                    'fieldInfos': [

                                    { 'fieldName': 'Name', 'label': 'Name' },

                                    { 'fieldName': 'Incident', 'label': 'Details', 'stringFieldOption': esri.dijit.AttributeInspector.STRING_FIELD_OPTION_RICHTEXT}

                    ]

                }

            ];

            var settings = {

                templatePicker: templatePicker,

                map: map,

                layerInfos: layers,

                toolbarVisible: true,

                createOptions: { polygonDrawTools: [esri.dijit.editing.Editor.CREATE_TOOL_FREEHAND_POLYGON] }

            };

            var params = {

                settings: settings

            };

            myEditor = new Editor(params, 'dialogeditorToolBar');

            myEditor.startup();

        };

     

        function stopEditing() {

            templatePicker.destroy();

            myEditor.destroy();

            dojo.create("div", {

                id: "dialogeditor"

            }, "legendDiv");

            dojo.create("div", {

                id: "dialogeditorToolBar"

            }, "legendDiv");

            functionMode = true;

        }

        //     hide TOC and Measure panes and create button toggles

        dojo.ready(function () {

            var leftPaneVis;

            var titlePaneDivVis;

            //set TOC and Measurement panes to be hidden at startup

         

            function hidePanes() {

                //   esri.hide(leftPaneOuterDiv);

                //     leftPaneVis = false;

                esri.hide(measureOuterDiv);

                titlePaneDivVis = false;

            };

            hidePanes();

            map.resize();

            dijit.byId('BorderContDiv').resize();

            dijit.byId("btnHide2").set("label", "Hide Layer List");

            // Show/Hide TOC Pane

            dojo.connect(dijit.byId("btnHide2"), "onClick", function () {

                if (leftPaneVis) {

                    esri.hide(leftPaneOuterDiv);

                    map.resize();

                    dijit.byId("btnHide2").set("label", "Show Layer List");

                    dijit.byId('map').resize();

                    dijit.byId('BorderContDiv').resize();

                    leftPaneVis = false;

                    return;

                }

                esri.show(leftPaneOuterDiv);

                map.resize();

                dijit.byId("btnHide2").set("label", "Hide Layer List");

                dijit.byId('BorderContDiv').resize();

                leftPaneVis = true;

            });

            // Show/Hide Measurement Pane

            dojo.connect(dijit.byId("btnHide3"), "onClick", function () {

                if (titlePaneDivVis) {

                    esri.hide(measureOuterDiv);

                    map.graphics.clear();

                    titlePaneDivVis = false;

                    return;

                }

                esri.show(measureOuterDiv);

                titlePaneDivVis = true;

            });

        });

        //// end hide/toggle TOC and Measure panes routine

        $("#EditorBtnDiv").click(function () {

            //if (!measureMode) {

            // if (Pict === undefined || Pict === false) {

            initEditor();

            //   };

            //};

            //Pict = true;

        });

        $("#identifyBtn").click(function () {

            stopEditing();

            //   };

            //};

            //Pict = true;

        });

        ///////////   show/hide Pictometry btn cursor

        Pict = false;

        dojo.connect(dijit.byId("PictometryBtn"), "onClick", function () {

            if (Pict) {

                Pict = false;

                return;

            }

            Pict = true;

        });

        /////////

        ///////////   show/hide Identify btn cursor

        IdentifyActive = false;

        dojo.connect(dijit.byId("identifyBtn"), "onClick", function () {

            if (IdentifyActive) {

                //   alert("testoff");

                //map.setMapCursor("default");

                //dijit.byId("map").set("style", "width:100%");

                IdentifyActive = false;

                return;

            }

            IdentifyActive = true;

        });

        /////////

        //north arrow

        dojo.byId("northarrow").innerHTML = "<img src='./js/my/images/north.png' />";

        //scalebar

        dojo.connect(map, "onLayersAddResult", function () {

            var scalebar = new esri.dijit.Scalebar({

                map: map,

                attachTo: "bottom-left",

                scalebarUnit: "english"

            });

        });

        $(document).ready(function () { /////  //$jQuery Doc Ready...////

                        ///

            var measurement = new Measurement({

                map: map

            }, dom.byId("measurementDiv"));

            measurement.on("measure-end", function (evt) {

                this.setTool(this.activeTool, false);

            });

            measurement.startup();

            ///

            measurement.deactivate = function () {

                this.setTool(this.activeTool, false);

            };

            measurement.on("measure-start", function (evt) {

                map.setMapCursor("default");

                //alert("measurestarted");

                if (handlerPictometry) {

                    handlerPictometry.remove();

                    map.setMapCursor("default");

                    //console.log(map);

                };

            });

            //end of measurement

            ///beginning of onlayersaddresult

            dojo.connect(map, "onLayersAddResult",

            (function () {

                ////pictometry

                //var handlerPictometry;

                $("#PictometryBtn").click(function (evt) {

                    measureMode = dojo.query(".esriButton .dijitButtonNode").some(function (node, index, arr) {

                        if (node.childNodes[0].checked) {

                            //at least one of the measure tools is active so disable identify

                            return true;

                        }

                    });

                    if (measureMode === true) {

                        measurement.deactivate();

                        map.graphics.clear();

                    };

                    //handlers

                    if (handlerPictometry) {

                        handlerPictometry.remove();

                        handlerPictometry = null;

                    } else {

                        if (eventHandlerIdentify) {

                            eventHandlerIdentify.remove();

                        };

                        map.setMapCursor("crosshair");

                        //activate pictometry handler

                        handlerPictometry = map.on("click", function (evt) {

                            var pt = esri.geometry.webMercatorToGeographic(evt.mapPoint);

                            var url = 'https://YOURpictometrySERVER/efs/default.php?' + 'lat=' + pt.y + '&lon=' + pt.x + '&inSR=2239&outSR=4326&' + 'user=username%40user.com&pass=123456123456';

                            //var url = 'http://cloudaddressforPictometryPublic/php/ipa.php?' + 'lat=' + pt.y + '&lon=' + pt.x;

                            window.open(url);

                            ///// remove after one click

                            handlerPictometry.remove();

                            map.setMapCursor("default");

                            Pict = false;

                            ////remove after one click

                            //  handlerPictometry.remove();  //hm, should we disable after one click and re-wire other handlers? Revisit later..

                        });

                    };

                    //};  //end measure if handler active test

                }); /// end Pictometry handler

                /// /pictometry

                //dojo.connect(map, 'onLayersAddResult', (function () {

                //    map.infoWindow.resize(390, 750);

                //}));

                dojo.create("div", {

                    id: "dialogeditorToolBar"

                }, "legendDiv");

            }));    //end of onlayersaddresult

        }); ////end of Document Ready jQuery

    }); // end of Ready()

   

});   //end of file

by Anonymous User
Not applicable

///example 2 index html

<!DOCTYPE html>

<html>

<head>

    <meta http-equiv="X-UA-Compatible" content="IE=edge" />

    <!--  Stylesheet links above the title, scripts below the title, just to provide some structure  -->

    <!--<link rel="stylesheet" type="text/css" href="js/lib/arcgis_js_api/library/3.5/3.5/js/dojo/dijit/themes/claro/claro.css" />-->

    <!--<link rel="stylesheet" type="text/css" href="js/lib/arcgis_js_api/library/3.5/3.5/js/esri/css/esri.css" />-->

    <link rel="stylesheet" href="http://js.arcgis.com/3.12/dijit/themes/claro/claro.css">

    <link rel="stylesheet" href="http://js.arcgis.com/3.12/esri/css/esri.css">

    <script src="js/my/dojoConfig.js"></script>

    <script src="http://js.arcgis.com/3.12/"></script>

    <!-- Stylesheet links to set orientation: note that these don't work in IE8 and below, and I don't care -->

    <link rel="stylesheet" type="text/css" media="all and (orientation:portrait)" href="css/portrait.css" />

    <link rel="stylesheet" type="text/css" media="all and (orientation:landscape)" href="css/landscape.css" />

    <link rel="stylesheet" type="text/css" href="css/layout.css" />

    <meta name="viewport" content="width=device-width, initial-scale=1.0" />

    <title>CNT Map Viewer</title>

   

    <link rel="stylesheet" href="http://code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">

    <script src="http://code.jquery.com/jquery-1.10.2.js"></script>

    <script src="http://code.jquery.com/ui/1.11.2/jquery-ui.js"></script>

    <!-- Load dojoConfig object first and seperate, cause the dojo docs says to -->

    <!--<script src="js/my/dojoConfig.js"></script>-->

    <!-- Load dojo.js, and tell it to parse on load -->

    <!--<script src="js/lib/arcgis_js_api/library/3.5/3.5/js/dojo/dojo/dojo.js" data-dojo-config="parseOnLoad: true"></script>-->

    <!-- require the dojo page items be loaded -->

    <!--<script> require(["dijit/layout/BorderContainer", "dijit/layout/ContentPane", "dijit/layout/AccordionContainer"]);</script>-->

    <!-- Load esri code per the api directions  -->

    <!--<script src="js/lib/arcgis_js_api/library/3.5/3.5/init.js"></script>-->

    <!--                <script src="js/lib/jsapi_vsdoc12_v33.js"></script> -->

    <!-- Load public web services references so I don't have to type later :)-->

    <script src="js/my/publicWebServiceURLs.js"></script>

    <!-- Load the script to actually do something, ideally, this is gonna be encapsulated into some modular functions -->

    <!--About window. Put this into a separate js file later -->

    <script type='text/javascript'>

        // Show About dialogue

        function showDialog() {

            dijit.byId("terms").show();

        }

        // Hide About dialogue

        function hideDialog() {

            dijit.byId("terms").hide();

            }

   

        </script>

   

   

 

    <script src="js/my/myMapNew.js"></script>

</head>

<body class="claro">

    <div id="pagewrap" style="overflow:hidden">

        <!--<div id="EditDivContainer">

            <div id="EditDivContainerInside" style="width: 150px; height: 140px;">

                <div id="dialogeditor">

                </div>

            </div>

            <br />

            <div id="dialogeditorToolbar"></div>

            <button data-dojo-type="dijit.form.Button" id="EditStartBtn" type="submit" style="z-index: 19999; overflow: visible;">Start Editing</button>

        </div>-->

        <div id="BorderContDiv" data-dojo-type="dijit/layout/BorderContainer"

             data-dojo-props="design:'headline',gutters:true"

             style="width: 100%; height:100%; margin: 0;">

            <div id="header"

                 data-dojo-type="dijit/layout/ContentPane"

                 data-dojo-props="region:'top'">

                <div id="bannercontainer" style="position:absolute; left:0px; top:0px">

                    <a href="http://www.thempc.org/SAGIS/Services.htm" id="bannerimage2" target="_blank">

                        <img src="./images/logoSmall.png"

                             border="0" />

                    </a>

                    <a href="" id="AirportLinkContainer" target="_blank">

                        <img src="./../images/logo.jpg" width="80"

                             border="0" />

                    </a>

                    <div id="bannerlink" style="position:absolute; right:10px; top:8px;">

                        <a class="CEMAlink" href="" target="_blank">Link to website</a>

                    </div>

                    <div id="HelpLink" style="position:absolute; right:152px; top:4px;">

                        <a class="HELPlink" href="./../SiteHelp.pdf" target="_blank">Map Viewer HELP</a>

                    </div>

                    <div id="HelpLinkSmallScreen" style="position:absolute; right:12px; top:4px;">

                        <a class="HELPlink" href="./../SiteHelp.pdf" target="_blank">Map Viewer HELP</a>

                    </div>

                    <!--                        <div id="ScaleDivContainer" style="position:absolute; right:235px; top:42px; height: 42px; width: 91px;">-->

                    <!--                             <span id="ScaleDiv" style="position:absolute; right:235px; top:42px; height: 42px; width: 91px; color:#000; z-index:99;"></span>-->

                    <!--                        </div>-->

                    <div id="Title" style="z-index: 189; position: absolute; top: 6px; margin-right: 0px;">  The  <br /> Site <br />   <b>Map Viewer</b> </div>

                    <!--Editor start...-->

                    <!--<div id="templatePickerDiv" style="position:absolute; right:2px; bottom:0; z-index: 899;">

                        <button data-dojo-type="dijit.form.Button" data-dojo-props="onClick:showDialogEditor">Editor</button>

                    </div>-->

                    <!-- vvv About vvvv (put styles into CSS) -->

                    <div id="AboutDiv" style="position: absolute; right: 31px; top: 40px; z-index: 899;">

                        <button id="AboutBtn" class="Abtn" data-dojo-type="dijit.form.Button" data-dojo-props="onClick:showDialog">About</button>

                    </div>

                    <div style="position: absolute; top: 50%; right: 50%; z-index: 210;">

                        <div class="dijitHidden">

                            <div data-dojo-type="dijit.Dialog" style="width: 500px;" data-dojo-props="title:'CNT Map Viewer'" id="terms">

                                <p style="text-align: center !important">

                                    <strong>

                                        This mapping website is provided by YOUR COMPANY HERE. <br />

                                    </strong>

                                </p>

                                <div style="height: 315px; overflow-y: no-display; border: 1px solid #769dc4; padding: 0 10px; width: 460px;">

                                    <span style="text-align: center; vertical-align: middle; display: table-cell">

                                        <br />

                                        <div id='AboutSagislogodiv' style='position:relative; left:30px; top:4px; height:90px; overflow:hidden; margin:0px;'>

                                            <img id="aboutlogo" src="./js/my/images/SAGISLogoCrop.png" />

                                        </div>

                                        <span style="text-decoration:underline; text-align: center;">For assistance with this website please contact:</span> <br />

                                        <br />

                                        Contact COMPANY by <a href="mailto:company@aol.com?Subject=The%20Viewer%20Web%20User%20Comment" target="_top">

                                            e-mail

                                        </a> or call 1111111 <br />and ask to speak with a staff member.

                                        <br /><br />

                                        Visit the homepage at <a href="" target="_blank"> address here </a> <br />

                                        <br />

                                        To view the Help Document for this website <a href="./../SiteHelp-CNT.pdf" target="_blank">click here.</a>

                                    </span>

                                    <br />

                                </div>

                                <button data-dojo-type="dijit.form.Button" data-dojo-props="onClick:hideDialog">OK</button>

                            </div>

                        </div>

                    </div>

                    <div style="z-index: 11000!important;">

                        <button data-dojo-type="dijit.form.Button" id="btnHide2" type="submit" style="position: absolute; right: 100px; top: 40px; z-index: 99; overflow: visible;">Show Layer List</button>

                        <button data-dojo-type="dijit.form.Button" id="btnHide3" type="submit" style="position: absolute; right: 235px; top: 40px; z-index: 99; overflow: visible;">Measure</button>

                        <div id="EditorBtnDiv">  <button data-dojo-type="dijit.form.Button" id="EditBtn" type="submit" style="position: absolute; right: 320px; top: 40px; z-index: 99; overflow: visible;">Start Editor</button></div>

                        <!--<div id="IdBtnDiv">  <button data-dojo-type="dijit.form.Button" id="IdBtn" type="submit" style="position: absolute; right: 395px; top: 40px; z-index: 99; overflow: visible;">Identify</button></div>-->

                        <button data-dojo-type="dijit.form.Button" id="PictometryBtn" type="submit" style="position: absolute; right: 528px; top: 40px; z-index: 99; overflow: visible;">Pictometry</button>

                        <button data-dojo-type="dijit.form.Button" id="identifyBtn" type="submit" style="position: absolute; right: 425px; top: 40px; z-index: 99; overflow: visible;">Stop Editor</button>

                    </div>

                </div>

                <div id="HeaderToolbarDiv" style="position:absolute; left:0px; bottom:0px;">

                    <!--<div id="GeocoderBoundingDiv" style="position:absolute; right:3px; bottom:0px;">

                            <div id="GeocoderDiv"></div>

                        </div>-->

                </div>

            </div>

            <div id="leftPaneOuterDiv">

                <div id="leading"

                     data-dojo-type="dijit/layout/ContentPane"

                     data-dojo-props="region:'leading', splitter:true"

                     style="width:25%;">

                    <div data-dojo-type="dijit/layout/AccordionContainer">

                        <div data-dojo-type="dijit/layout/ContentPane" title="CNT Editor">

                            <div id="legendDiv">

                                <div id="dialogeditor"></div>

                            </div>

                        </div>

                       

                        <div data-dojo-type="dijit/layout/ContentPane" title="CNT Points">

                            <div id="CNTpointsTOC">

                                </div>

                        </div>

                        <div data-dojo-type="dijit/layout/ContentPane" title="Map Layers">

                            <div id="operationalLayers"></div>

                        </div>

                        <!--<div data-dojo-type="dijit/layout/ContentPane" title="Airport Layout Plan Layers">

                            <div id="alpLayersDiv"></div>

                        </div>-->

                        <div data-dojo-type="dijit/layout/ContentPane" title="Basemaps & Imagery">

                            <div id="BasemapsDiv"></div>

                        </div>

                    </div>

                </div>

            </div>

            <div id="map"

                 data-dojo-type="dijit/layout/ContentPane"

                 data-dojo-props="region:'center'">

                <span id="northarrow" style="position:absolute; left:173px; bottom:8px; color:#000; z-index:50;"></span>

                <span id="status" style="position: absolute; z-index: 100; left: 20px; bottom: 20px;">

                    Loading...

                </span>

                <div id="measureOuterDiv" style="position:absolute; right:20px; top:10px; z-Index:999;">

                    <div id="titlePane" data-dojo-type="dijit.TitlePane" data-dojo-props="region:'center', title:'Measurement', closable:'true', open:'false'">

                        <div id="measurementDiv"></div>

                        <span style="font-size:smaller;padding:5px 5px;">Click a measurement tool to activate. <br />Double-click on the map where you wish to finish the measurement.</span>

                    </div>

                </div>

            </div>

        </div>

    </div>

</body>

</html>

0 Kudos
by Anonymous User
Not applicable

//example 2 css

html,body {

        height:100%;

        width:100%;

        margin:0;

       }

#SAGISLinkContainer {z-index: 100; width:200px; height:90px; position:absolute }

#SAGISLinkClicker { display:block; width:201px;

height:90px; position:absolute; top:0px; left:-15px; }

#AirportLinkContainer { 

position:absolute;

    top: 0px;

    left: 205px;

}

#status {

        background-color: black;

        color: white;

     font-size: 16pt;

        padding: 3px;

        border: solid 3px white;

        border-radius: 5px;

      }

.CEMAlink {

    font-weight: bold;

  text-decoration: none;

        font-size: 10pt ;

  color: #0000cd;

      text-decoration:underline;

   

}

.HELPlink {

    font-weight: bold;

  text-decoration: none;

    font-size: 14pt ;

  color: #0000cd;

      text-decoration:underline;

   

}

#Title {

z-index:90;

    position:absolute;

    left: 430px;

    width: 370px!important;

    bottom: 467px;   

    color:#191970;

    font-size:22px;

    font-weight:bold;

    text-align: center;

    height: 56px;

    width: 456px;

}

#header {

    height:66px;

    overflow:hidden;

    background-color: white;

    margin: 0;

    min-height:66px

}

a:hover {

  text-decoration:underline;

  color:#b200ff;

}

a, img {

    border:none;

}

#bannercontainer

{

    height: 100%;

    width:100%;

    position:relative;

    overflow:hidden;

}

#bannerimage

{   

    position:absolute;

    left:191px;

    top:0;

    bottom: 473px;

}

#bannerimage2

{   

    position:absolute;

    left:0px;

    top:0px;

}

#bannerlink

{

    z-index:90;

    position:relative;   

    color:#fffa00;

    font-size:18px;

    font-weight:bold;

    right:8px;

    top:10px;

    overflow:hidden;

        }

#titlePane{

        width:240px;

    margin-left: 0px;

}

      .claro .dijitTitlePaneTitle {

        background: #f8f8ff;

        font-weight:600;

        border:solid 1px #29201A;

      }

      .claro .dijitTitlePaneTitleHover {

        background:#fff8dc;

      }

      .claro .dijitTitlePaneTitleActive {

        background:#f8f8ff;

      }

.claro .dijitTitlePaneContentOuter {

    border-right: solid 2px #f8f8ff !important;

    border-bottom: solid 2px #f8f8ff !important;

    border-left: solid 2px #f8f8ff !important;

}

@media all and (max-width: 1320px) {

    #bannerlink

{ display: none; }

}

  @media all and (max-width: 1320px) {

    #HelpLink

{ display: none; }

}

    @media all and (min-width: 1320px) {

    #HelpLinkSmallScreen

{ display: none; }

}

        @media all and (max-width: 700px) {

    #HelpLinkSmallScreen

{ display: none; }

}

  @media all and (max-width: 1315px) {

    #Title

{ display: none; }

}

  /* below necessary to fix ESRI weirdness with bar in bottom right... bar worked in other corners button i want bottom right */

  /*.scalebar_bottom-right {

right: 200px !important;

}*/

  /*new CSS for editor*/

    .templatePicker {

        border:solid 2px #232416 !important;

      }

     .dj_ie .infowindow .window .top .right .user .content { position: relative; }

      .dj_ie .simpleInfoWindow .content {position: relative;} 

      .esriAttributeInspector .atiRichTextField .dijitEditorIFrameContainer{

        height:60px;}

      /*ovverride because of scrollbars input editor infowindow*/

      .contentPane {

          overflow: hidden !important;

      }

   

     

#legendDiv {

 

    position: absolute;

    top: 30px;

    height: 605px;

    width: 285px;

    z-index: 990;

        overflow: hidden;

}

#dialogeditor {

    position: absolute;

    top: 44px;

     height: 145px;

    width: 260px;

        z-index: 997;

    overflow: hidden;

}

#dialogeditorToolbar {

    position: absolute;

    top: 211px;

     height: 45px;

    width: 260px;

        z-index: 999;

            overflow: hidden;

}

.atiRichTextField {

    width:auto;

    height: auto;

}

0 Kudos
by Anonymous User
Not applicable

Sorry for all the crud here. For obvious reasons, Example 2 won't work on JS Fiddle.

For some reason Example 1 works perfect in ESRI Sanbox but not JS Fiddle. I haven't taken the time to fix it. If someone wants to fix it, then publish it out as a Fiddle that would be just fine though.

Good luck, hope this helps someone.

0 Kudos
ChrisSergent
Regular Contributor III

Sharing code is always a good thing. Saves everyone time.

0 Kudos