Skip to content

Instantly share code, notes, and snippets.

@spSlaine
Created August 9, 2019 07:30
Show Gist options
  • Save spSlaine/687535b245dc3728fc930da4e3aab3ed to your computer and use it in GitHub Desktop.
Save spSlaine/687535b245dc3728fc930da4e3aab3ed to your computer and use it in GitHub Desktop.
Sketch widget - 4.12
<!--
ArcGIS API for JavaScript, https://js.arcgis.com
For more information about the sketch-geometries sample, read the original sample description at developers.arcgis.com.
https://developers.arcgis.com/javascript/latest/sample-code/sketch-geometries/index.html
-->
<div id="viewDiv"></div>
require([
"esri/widgets/Sketch",
"esri/Map",
"esri/layers/GraphicsLayer",
"esri/views/MapView"
], function(Sketch, Map, GraphicsLayer, MapView) {
const layer = new GraphicsLayer();
const map = new Map({
basemap: "streets",
layers: [layer]
});
const view = new MapView({
container: "viewDiv",
map: map,
zoom: 5,
center: [90, 45]
});
const sketch = new Sketch({
layer: layer,
view: view,
availableCreateTools: ['polygon']
});
view.ui.add(sketch, "top-right");
});
<script src="https://js.arcgis.com/4.12/"></script>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
<link href="https://js.arcgis.com/4.12/esri/themes/light/main.css" rel="stylesheet" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment