Select to view content in your preferred language

Help with Sketch Widget Tooltip Units

527
2
05-15-2024 07:25 AM
FlockSafety
Emerging Contributor

Hello,

I would like to change the units displayed on the Sketch widget tooltip from meters to miles. I combed through the documentation and couldn't find any way to configure this. Our application stores the distance and area (plus the units) in miles, but we are having trouble displaying the built-in measurement while drawing in miles.

The tooltip in the screenshot is displayed using the "tooltipOptions={{ enabled: true }}" parameter for the Sketch Widget

The only alternative I found was to make a TextSymbol located at the centroid lat/lng of the polygon. But this felt clunky to implement given there is already a dynamic tooltip in the SDK.

 

FlockSafety_0-1715783067466.png

 

2 Replies
AlexQuintero1
Occasional Contributor

I am running into the same issue. Doesn't appear that it can be changed.

0 Kudos
Katie_Clark
MVP Alum

I was able to accomplish this by explicitly setting the valueOptions > displayUnits property for the Sketch class. Here's an example of how I'm using it:

const sketchWidget = new Sketch({
      layer: sketchLayer,
      view: view,
      viewModel: sketchViewModel,
      valueOptions: {
        displayUnits: {
          length: "feet",
          area: "acres"
        }
      },
      visibleElements: {
        duplicateButton: false,
        createTools: {
          point: geometryTypes.includes("point"),
          polyline: geometryTypes.includes("polyline"),
          polygon: geometryTypes.includes("polygon"),
          rectangle: false,
          circle: false
        }
      },
      defaultUpdateOptions: {
        reshapeOptions: {
          shapeOperation: "none"
        },
        enableRotation: false,
        enableScaling: false,
        enableZ: false,
        highlightOptions: {
          enabled: false
        },
        tool: "reshape"
      },
      creationMode: "update"
    });

 
Here's a link to the documentation - it says it's in beta so perhaps this feature wasn't available when this post was originally made. It's supported since ArcGIS Maps SDK for JavaScript 4.29.

Hope this helps if someone comes across this post in the future!

Best,
Katie

If this answer helped you, please consider giving a kudos and/or marking as the accepted solution. Thanks!
0 Kudos