So I have put together a rudimentary widget that allows an internal department to generate Buffers around a point based on precise requirements that they have. They need to click a point on the map and generate a 1,000 and a 3,000 foot buffer.
Assistance Building First Widget : Buffer Points?
So I've got it working.
However, when you measure from the center to the edge of the buffers you don't get 1,000 nor 3,000 feet buffers on screen. The buffer that is supposed to be 1,000 feet is 800 feet and the 3,000 is more like 2,500 feet?!
Any ideas? Robert Scheitlin, GISP?
Solved! Go to Solution.
Brain,
You need to specify the buffers spatial reference (line 17, 44, 67):
define([
'dojo/_base/declare',
'jimu/BaseWidget',
'dijit/_WidgetsInTemplateMixin',
"dojo/dom",
"dojo/_base/array",
"dojo/parser",
"dojo/query",
"dojo/on",
"dojo/_base/lang",
"esri/Color",
"esri/config",
"esri/map",
"esri/graphic",
"esri/geometry/normalizeUtils",
"esri/tasks/GeometryService",
"esri/SpatialReference",
"esri/tasks/BufferParameters",
"jimu/dijit/DrawBox",
"esri/symbols/SimpleMarkerSymbol",
"esri/symbols/SimpleLineSymbol",
"esri/symbols/SimpleFillSymbol",
"dijit/layout/BorderContainer",
"dijit/layout/ContentPane",
"dijit/form/Button",
"dojo/domReady!"
],
function(
declare,
BaseWidget,
_WidgetsInTemplateMixin,
dom,
array,
parser,
query,
on,
lang,
Color,
esriConfig,
Map,
Graphic,
normalizeUtils,
GeometryService,
SpatialReference,
BufferParameters,
DrawBox,
SimpleMarkerSymbol,
SimpleLineSymbol,
SimpleFillSymbol
) {
.....
createCOTBuffers: function(evtObj) {
this.drawBox.deactivate();
var geometry = evtObj.geometry,
symbol;
symbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_SQUARE, 10, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255, 0, 0]), 1), new Color([0, 255, 0, 0.25]));
var graphic = new Graphic(geometry, symbol);
this.map.graphics.add(graphic);
this.drawBox.clear();
//setup the buffer parameters
var params = new BufferParameters();
params.distances = [this.firstDistance.value, this.secondDistance.value];
params.outSpatialReference = this.map.spatialReference;
params.unit = GeometryService[this.unit.value];
params.bufferSpatialReference = new SpatialReference({wkid: 102003})
//normalize the geometry
normalizeUtils.normalizeCentralMeridian([geometry]).then(lang.hitch(this, function(normalizedGeometries) {
var normalizedGeometry = normalizedGeometries[0];
params.geometries = [normalizedGeometry];
esriConfig.defaults.geometryService.buffer(params, lang.hitch(this, this.showCOTBuffers));
}));
},
Brain,
You need to specify the buffers spatial reference (line 17, 44, 67):
define([
'dojo/_base/declare',
'jimu/BaseWidget',
'dijit/_WidgetsInTemplateMixin',
"dojo/dom",
"dojo/_base/array",
"dojo/parser",
"dojo/query",
"dojo/on",
"dojo/_base/lang",
"esri/Color",
"esri/config",
"esri/map",
"esri/graphic",
"esri/geometry/normalizeUtils",
"esri/tasks/GeometryService",
"esri/SpatialReference",
"esri/tasks/BufferParameters",
"jimu/dijit/DrawBox",
"esri/symbols/SimpleMarkerSymbol",
"esri/symbols/SimpleLineSymbol",
"esri/symbols/SimpleFillSymbol",
"dijit/layout/BorderContainer",
"dijit/layout/ContentPane",
"dijit/form/Button",
"dojo/domReady!"
],
function(
declare,
BaseWidget,
_WidgetsInTemplateMixin,
dom,
array,
parser,
query,
on,
lang,
Color,
esriConfig,
Map,
Graphic,
normalizeUtils,
GeometryService,
SpatialReference,
BufferParameters,
DrawBox,
SimpleMarkerSymbol,
SimpleLineSymbol,
SimpleFillSymbol
) {
.....
createCOTBuffers: function(evtObj) {
this.drawBox.deactivate();
var geometry = evtObj.geometry,
symbol;
symbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_SQUARE, 10, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255, 0, 0]), 1), new Color([0, 255, 0, 0.25]));
var graphic = new Graphic(geometry, symbol);
this.map.graphics.add(graphic);
this.drawBox.clear();
//setup the buffer parameters
var params = new BufferParameters();
params.distances = [this.firstDistance.value, this.secondDistance.value];
params.outSpatialReference = this.map.spatialReference;
params.unit = GeometryService[this.unit.value];
params.bufferSpatialReference = new SpatialReference({wkid: 102003})
//normalize the geometry
normalizeUtils.normalizeCentralMeridian([geometry]).then(lang.hitch(this, function(normalizedGeometries) {
var normalizedGeometry = normalizedGeometries[0];
params.geometries = [normalizedGeometry];
esriConfig.defaults.geometryService.buffer(params, lang.hitch(this, this.showCOTBuffers));
}));
},