AnsweredAssumed Answered

Geocode Address then Buffer

Question asked by jay.kapalczynski on Aug 1, 2014
Latest reply on Aug 1, 2014 by jay.kapalczynski

I am trying to Geocode an Address then Buffer that address....from there I want to use that buffered graphic for further queries...

 

I can get the Geocode to work but stuck on getting the Buffer code to create the buffered graphic of which I need to use its geometry to run further queries..

 

Am I way off here?

 

 

// GEOCODER START===========================================================================================

 

var x = "";

var y = "";

 

  var geocoder = new Geocoder({

   arcgisGeocoder: {

  placeholder: "4010 West Broad St, RIchmond, Virginia"

   },

   autoComplete: true,

   map: app.map,

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

  geocoder.startup();

 

    geocoder.on("select", showLocation);

    geocoder.on("clear", removeSpotlight);

 

        function showLocation(evt) {

          //app.map.graphics.clear();

          var point = evt.result.feature.geometry;

 

  x = point.x

  y = point.y

 

 

          var symbol = new SimpleMarkerSymbol().setStyle(

            SimpleMarkerSymbol.STYLE_circle).setColor(

            new Color([255,0,0,0.5])

          );

          var graphic = new Graphic(point, symbol);

          app.map.graphics.add(graphic);

 

// ATTAMPT TO BUFFER THE RETURNED LOCATION

//----------------------------------------------------------------------------------------

  var paramsGC = new BufferParameters();

  paramsGC.geometries  = graphic;

  paramsGC.distances = [ .5 ];

  //paramsGC.bufferSpatialReference = new SpatialReference({wkid: 26917});

  paramsGC.outSpatialReference = app.map.spatialReference;

  paramsGC.unit = GeometryService.UNIT_STATUTE_MILE;

 

 

        // geometry service that will be used to perform the buffer

        var geometryServiceGC = new GeometryService("https://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");

  geometryServiceGC.buffer(paramsGC);

        geometryServiceGC.on("buffer-complete", function(result){

 

 

          app.map.graphics.clear();

 

 

          // draw the buffer geometry on the map as a map graphic

          var symbol2 = new SimpleFillSymbol(

            SimpleFillSymbol.STYLE_NULL,

            new SimpleLineSymbol(

              SimpleLineSymbol.STYLE_SOLID,

              new Color([105,105,105]),

              2

            ),new Color([255,255,0,0.25])

          );

          var bufferGeometryGC = result.geometries[0]

          var graphicGC = new Graphic(bufferGeometryGC, symbol2);

          app.map.graphics.add(graphicGC);

  });

//-----------------------------------------------------------------------------------------

 

 

// GEOCODER END===================================================================================================

Outcomes