How to remove the undo and redo button on a sketch widget?

1399
3
Jump to solution
03-09-2020 12:53 AM
SiyabongaKubeka
Occasional Contributor

Hi All

How does one remove the undo and redo button on a sketch widget? Please see my code below:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="initial-scale=1,maximum-scale=1,user-scalable=no"
/>
<title>DEA GIS APPLICATION</title>

<link
rel="stylesheet"
href="https://js.arcgis.com/4.12/esri/themes/light/main.css"
/>
<script src="https://js.arcgis.com/4.12/"></script>

<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<script>
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]
});

var symbol = {
type: "simple-marker", // autocasts as new SimpleMarkerSymbol()
style: "circle",
color: "blue",
size: "8px", // pixels
outline: { // autocasts as new SimpleLineSymbol()
color: [ 255, 255, 0 ],
width: 1 // points
}
};

const sketch = new Sketch({
layer: layer,
view: view,
symbol: symbol,
availableCreateTools: ["point"]
});

view.ui.add(sketch, "top-right");

sketch.on('create', function (evt) {
if (view.zoom >= 11) {
// check if the create event's state has changed to complete indicating
// the graphic create operation is completed.
let gra = evt.graphic.clone();
evt.graphic.layer.removeAll();
gra.symbol.color = "blue";
layer.add(gra);
console.log("X = ", gra.geometry.x);
console.log("Y = ", gra.geometry.y);
} else {
alert("please zoom in");
evt.graphic.layer.remove(evt.graphic);
}
});
});
</script>
</head>

<body>
<div id="viewDiv"></div>
</body>
</html>

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Just add these two css rules:

    .esri-sketch__section.esri-sketch__tool-section:last-of-type {
      display:none;
    }
    .esri-sketch__section.esri-sketch__tool-section:nth-child(2) {
      border-right: none;
    }

View solution in original post

3 Replies
RobertScheitlin__GISP
MVP Emeritus

Just add these two css rules:

    .esri-sketch__section.esri-sketch__tool-section:last-of-type {
      display:none;
    }
    .esri-sketch__section.esri-sketch__tool-section:nth-child(2) {
      border-right: none;
    }
SiyabongaKubeka
Occasional Contributor

Hi Robert,

Do I add them inside the style or inside the sketch widget?

0 Kudos
SiyabongaKubeka
Occasional Contributor

Thank you very much Robert

0 Kudos