Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm using the below sample and i want to change the queried results from points to polygons

http://help.arcgis.com/en/webapi/jav...ry_buffer.html

Probably very simple but cant get my head around where to change it.

I tried replacing the queryTask to http://sampleserver1.arcgisonline.co...SA/MapServer/1 and changing the symbol style to reflect this but it didnt seem to make much difference. I'm sure that somewhere and i cant see where, i need to make reference to the fact that we are now querying polygon and not point data.

share|improve this question
    
The 1st link doesn't work –  Hairy Aug 1 '11 at 13:20
    
    
Do you have the proxy page set up correctly? I've had problems in the past when I overlooked that piece. –  mrohlf Aug 1 '11 at 19:14

1 Answer 1

up vote 1 down vote accepted

The buffer user-defined graphics sample shows how to buffer points, line and polygons.

A graphic is added to the map for the user-defined geometry and then that geometry is sent to a geometry service be buffered:

function doBuffer(geometry) {
  switch (geometry.type) {
     case "point":
       var symbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE, 10, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255,0,0]), 1), new dojo.Color([0,255,0,0.25]));
       break;
     case "polyline":
       var symbol = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DASH, new dojo.Color([255,0,0]), 1);
       break;
     case "polygon":
       var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_NONE, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DASHDOT, new dojo.Color([255,0,0]), 2), new dojo.Color([255,255,0,0.25]));
       break;
  }

  var graphic = new esri.Graphic(geometry, symbol);
  map.graphics.add(graphic);

  //setup the buffer parameters
  var params = new esri.tasks.BufferParameters();

  params.distances = [ dojo.byId("distance").value ];
  params.bufferSpatialReference = new esri.SpatialReference({wkid: dojo.byId("bufferSpatialReference").value});
  params.outSpatialReference = map.spatialReference;
  params.unit = eval("esri.tasks.GeometryService."+dojo.byId("unit").value);

  if (geometry.type === "polygon") {
    //if geometry is a polygon then simplify polygon.  This will make the user drawn polygon topologically correct.
    gsvc.simplify([geometry], function(geometries) {
      params.geometries = geometries;
      gsvc.buffer(params, showBuffer);
    });
  } else {
    params.geometries = [geometry];
    gsvc.buffer(params, showBuffer);
  }
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.