AnsweredAssumed Answered

Attribute Inspector Syntax

Question asked by thebillcarr on Dec 18, 2014

I'm attempting to expand on a previous app that adds a point to the map based on a users mobile location. I got that part working fine, the issue is that now I need it to open the attribute inspector after clicking a button. I can confirm that the point is being added to my server, but the attribute inspector isn't displaying. I know this is due to the sample code from Using the attribute inspector | ArcGIS API for JavaScript using a different event, I'm just unsure how to adjust the variables in the functions.

 

Any help is greatly appreciated.

 

 

Sample:

   function initSelectToolbar(evt) {

          var petroFieldsFL = evt.layers[0].layer;

          var selectQuery = new Query();

 

 

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

            selectQuery.geometry = evt.mapPoint;

            petroFieldsFL.selectFeatures(selectQuery, FeatureLayer.SELECTION_NEW, function(features) {

           

                //store the current feature

                updateFeature = features[0];

                map.infoWindow.setTitle(features[0].getLayer().name);

                map.infoWindow.show(evt.screenPoint, map.getInfoWindowAnchor(evt.screenPoint));

 

 

What I got:

      //get a reference to the element

var myBtnn = document.getElementById('myBtnn');

 

 

//add event listener

myBtnn.addEventListener('click',

       function docking(){

  console.log("bwahhhhh1");

         

// using static point for testing purposes

          var pt = new Point( -84.960736,32.277353);

          if ( !graphic ) { 

            addGraphic(pt); 

          } else { // move the graphic if it already exists 

            graphic.setGeometry(pt); 

          } 

 

        });

        var geometry; 

        function addGraphic(pt){ 

          var symbol = new SimpleMarkerSymbol( 

            SimpleMarkerSymbol.STYLE_CIRCLE,  

            12); 

          graphic = new Graphic(pt, symbol); 

          map.graphics.add(graphic); 

        console.log("bwahhhhh2");

          new esri.geometry.Point(pt, map.spatialReference); 

           

          var newFeature = new esri.Graphic(geometry, null,null); 

featureLayer.applyEdits([newFeature], null, null, function () {}, function() {}); 

 

console.log("bwahhhhh22");

 

            var layerInfoss = [

             { 'featureLayer': featureLayer,

            'showAttachments': false,

            'isEditable': true}

            ];

 

 

    

                  var attInspector = new AttributeInspector({

            layerInfos:layerInfoss

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

          console.log("tell me it works ricky!!");

         

          //add a save button next to the delete button

          var saveButton = new Button({ label: "Save", "class": "saveButton"});

          domConstruct.place(saveButton.domNode, attInspector.deleteBtn.domNode, "after");

        

          saveButton.on("click", function(pt){

          updateFeature = featureLayer;

            updateFeature.getLayer().applyEdits(null, [updateFeature], null);    

               console.log("tell me it works julian!!");   

          });

         

          attInspector.on("attribute-change", function(pt) {

          updateFeature = featureLayer;

            //store the updates to apply when the save button is clicked

            updateFeature.attributes[fieldName] = fieldValue;

            updateFeature.getLayer().applyEdits(null, [updateFeature], null);  

               console.log("tell me it works bubbles!!");

          });

         

          attInspector.on("next", function(pt) {

            updateFeature = featureLayer;

            updateFeature.getLayer().applyEdits(null, [updateFeature], null);  

               console.log("tell me it works corey!!");

            console.log("Next " + updateFeature.attributes.objectid);

          });

         

          attInspector.on("delete", function(pt){

            newFeature.getLayer().applyEdits(null,null,[featureLayer]);

               console.log("tell me it works trevor!!");

            map.infoWindow.hide();

          });

          map.infoWindow.setContent(attInspector.domNode);

          map.infoWindow.resize(350, 240);

             console.log("tell me it works randy!!");

    

        } 

Outcomes