Proper Use of geometryEngine.geodesicBuffer?

1925
2
Jump to solution
12-03-2018 01:01 PM
Arne_Gelfert
Occasional Contributor III

Been learning how to use the ArcGIS Javascript API v4.9. But despite the countless examples online, I keep into bumping into seemingly "small" things that just don't work. For example, creating a buffer around a point and then adding that buffer to a graphics layer. I've used the code here which works for me, and have stripped it down to the minimum in hopes of adapting it to what I'm working on. But now I'm getting this error:

What is the "_geVersion" - a reference to geometry engine version? Why is that undefined? Any pointers are appreciated.My point is added to the map just fine. The buffer is what I'm trying to get working. Here is my code:

require([
"esri/Map",
"esri/views/MapView",
"esri/layers/GraphicsLayer",
"esri/Graphic",
"esri/geometry/geometryEngine"

], function(
Map,
MapView,
GraphicsLayer,
Graphic,
geometryEngine
) {

// Create Map instance
let map = new Map({
basemap: "topo-vector"
});

//Create View Instance
let view = new MapView({
container: "viewDiv",
map: map,
center: [-90,45],
zoom: 10
});

var bufferLayer = new GraphicsLayer();
var pointLayer = new GraphicsLayer();
map.addMany([bufferLayer, pointLayer]);
var polySym = {
type: "simple-fill", // autocasts as new SimpleFillSymbol()
color: [140, 140, 222, 0.5],
outline: {
color: [0, 0, 0, 0.5],
width: 2
}
};

var pointSym = {
type: "simple-marker", // autocasts as new SimpleMarkerSymbol()
color: [255, 0, 0],
outline: {
color: [255, 255, 255],
width: 1
},
size: 7
};
let point = {
type: "point",
longitude : -90.0,
latitude : 45.0};
pointLayer.add(new Graphic({
geometry: point,
symbol: pointSym
   })
);

var buffer = geometryEngine.geodesicBuffer(point, 10, "kilometers");
bufferLayer.add(new Graphic({
geometry: buffer,
symbol: polySym
}
));

});
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Arne,

   The issue is that GeometryEngine does not autoCast the geometry property and you are only providing an object and not an actual geometry class like Point class.

View solution in original post

0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Emeritus

Arne,

   The issue is that GeometryEngine does not autoCast the geometry property and you are only providing an object and not an actual geometry class like Point class.

0 Kudos
Arne_Gelfert
Occasional Contributor III

Nice! I knew I was missing something simple...Thanks, Robert!

Tweaked as per below, and not it works:

     let point = {
     type: "point",
     longitude : -90.0,
     latitude : 45.0};
     let pointObj = new Point({
     latitude : point.latitude,
     longitude : point.longitude,
     spatialReference : map.spatialReference
     })
     pointLayer.add(new Graphic({
     geometry: point,
     symbol: pointSym
     }));

     var buffer = geometryEngine.geodesicBuffer(pointObj, 10, "kilometers");
     bufferLayer.add(new Graphic({
     geometry: buffer,
     symbol: polySym
     }));
0 Kudos