Hide Table of Contents
View Geometry Engine - Geodesic buffers sample in sandbox
Geometry Engine - Geodesic buffers


This sample demonstrates how to create geodesic buffers using Geometry Engine. The result depicts areas located within 2000km of an earthquake.

The map in this application is built from an existing map in ArcGIS Online. Features from a point layer inside the map are extracted and input as geometries into the geodesicBuffer() method of GeometryEngine. Additional parameters including buffer distance, units, and whether to union the resulting features are also passed into the method. As opposed to GeometryService, GeometryEngine processes buffers on the client, generating and displaying the resulting features quickly and seamlessly.


<!DOCTYPE html>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
<title>Geodesic Buffers</title>
<link rel="stylesheet" href="https://js.arcgis.com/3.46/esri/css/esri.css" />
  html, body, #map { height: 100%; width: 100%; margin: 0; padding: 0; }

  h3 { margin: 0 0 5px 0; border-bottom: 1px solid #444; }
  .shadow {
    -moz-box-shadow: 0 0 5px #888;
    -webkit-box-shadow: 0 0 5px #888;
    box-shadow: 0 0 5px #888;
  #feedback {
    background: #fff;
    bottom: 30px;
    color: #444;
    position: absolute;
    font-family: arial;
    height: 140px;
    left: 30px;
    margin: 5px;
    padding: 10px;
    width: 300px;
    z-index: 40;
  #note { font-size: 80%; font-weight: 700; padding: 0 0 10px 0; }

<script src="https://js.arcgis.com/3.46/"></script>
], function(
) {

    //csv file from a webserver (usgs.gov), basemap, rederer, custom popup are conatined in this simple webmap.
    var webmapId = "00fbe4fffaca422aa3fb6085a0f65ade";

    arcgisUtils.createMap(webmapId, "map",{
      mapOptions: {slider: false}
      var map = response.map;

      //when the map is ready geodesically buffer all features

    function bufferEarthquakes(map){
      //Pull first layer from the webmap and use it as input for the buffer operation
      //Use GeometryEngine geodesicBuffer
      //buffers will have correct distance no matter what the spatial reference of the map is.

      var featureLayer = map.getLayer(map.graphicsLayerIds[0]);
      var geometries = graphicsUtils.getGeometries(featureLayer.graphics);

      //geodesicBuffer(geometries, [distance], unit, unionResults);
      var bufferedGeometries = geometryEngine.geodesicBuffer(geometries, [2000], "kilometers", true);

      //when buffer is done set up renderer and add each geometry to the map's graphics layer as a graphic
      var symbol = new SimpleFillSymbol();
      symbol.setColor(new Color([100,100,100,0.25]));
        map.graphics.add(new Graphic(geometry,symbol));


  <div id="map">
    <div id="feedback" class="shadow">
      <h3>Geodesic buffers of data in a webmap from ArcGIS.com</h3>
      <div id="info">
        <div id="note">
          The areas in gray are 2,000 kilometers from a recent magnitude 4.5 earthquakes and greater. Geodesic buffers (as opposed
          to Euclidean) are used to show a more accurate areas.

Show Modal