AnsweredAssumed Answered

SketchViewModel type

Question asked by gregb_mcpao on Oct 12, 2020
Latest reply on Oct 14, 2020 by gregb_mcpao

I am using a point widget to select an area on the map and highlight it. I then provide a geodesicBuffer to add distance in feet to query for intersecting areas. This is working, but the measurement is taken from the point when I need it taken from the bounding box. Is there a way on create to change the geometry type from a type point to a type rectangle?

 

Point widget. Buffer distance needs to be from bounding box, not point.

 

Polygon widget. Buffer selection is correct.

 

// create a point widget button and add to view

 

let button = document.createElement('button');
button.setAttribute("class","esri-widget--button esri-icon-map-pin geometry-button");
button.setAttribute("id","point-geometry-button");
button.setAttribute("value","point");

 

// add event to make selection on map

 

document.getElementById("point-geometry-button").addEventListener("click", geometryButtonsClickHandler);

 

// set the sketchviewmodel to a point

 

function geometryButtonsClickHandler(event) {

   const geometryType = event.target.value;
   sketchViewModel.create(geometryType);

}

 

// how to change to type:"rectangle" ?

 

sketchViewModel.on("create", function (event) {
   if (event.state === "complete") {
      sketchGeometry = event.graphic.geometry; //<---"point"
   }
});

Outcomes