AnsweredAssumed Answered

Add SimpleMarkerSymbol to Geocoder

Question asked by DCSD_gmarrero on Jun 16, 2015
Latest reply on Jun 22, 2015 by DCSD_gmarrero

I'm currently updating the Geocoder in WAB to work like the link below but I can't figure out how to add a marker when an address is found. Can someone tell me why this code is not adding a graphic after inputting an address in the geocoder?

 

Trigger Layer(s) Popup with Feature.Geometry

 

 

      onFindResults: function(results) {

        //Check to see if the user typed an MGRS or USNG string

        this.lastMgrsResult = this.lookupMgrs(results.results.value);

        if (null !== this.lastMgrsResult) {

          // Get reference ellipsoid coordinates of the current coordinate system

          // var mapWkid = this.map.spatialReference.wkid;

          // var srWkid = csUtils.isProjectedCS(mapWkid) ?

          //csUtils.getGeoCSByProj(mapWkid) : mapWkid;

          //Make a new object just like the objects in results.results.results

          var point = new Point(

            this.lastMgrsResult.longitude,

            this.lastMgrsResult.latitude,

            new SpatialReference({

              wkid: 4326 //srWkid   should use the ellipsoid SR of the current coordinate system

            }));

          var extent = this.map.extent.centerAt(point);

   var symbol = new SimpleMarkerSymbol();

  symbol.setStyle(SimpleMarkerSymbol.STYLE_SQUARE);

  symbol.setColor(new Color([153,0,51,0.75]));

          var graphic = new esri.Graphic(point, symbol);

   map.graphics.add(graphic);

          var resultObject = {

            extent: extent,

            feature: feature,

            name: this.lastMgrsResult.text

          };

          //Insert at start of results list

          results.results.results.unshift(resultObject);

        }

      },

Outcomes