SketchTooltipOptions length units support

664
3
Jump to solution
10-24-2022 07:44 AM
FabricioBezerra
New Contributor II

Hi, I'd like to know if it's currently possible to change the length units for the SketchTooltipOptions. By default, the lengths are displayed in the metric system and I wasn't able to find a way to change it to imperial units.

Thank you

1 Solution

Accepted Solutions
SaschaBrunnerCH
Esri Contributor

Hi Fabricio.
Thanks for reaching out.
With the current release (4.25) it derives the units either from:
- if "view.map" created from WebScene/WebMap and user logged in it gets the units (metric or imperal) from the user's configuration.
- or from the unit of the spatial reference

 At the moment it is not possible to change it on the SketchTooltipOptions directly, but this could change in an upcoming release.

In the meantime, a way to change the unit between metric and imperial is on the `view.map.portalItem`:

map.portalItem = new PortalItem({
  portal: { units: "english" }
}); 

or if portalItem already exist with instantiating from WebMap or WebScene:

map.portalItem.units = "english" 

I hope that helps.

View solution in original post

3 Replies
SaschaBrunnerCH
Esri Contributor

Hi Fabricio.
Thanks for reaching out.
With the current release (4.25) it derives the units either from:
- if "view.map" created from WebScene/WebMap and user logged in it gets the units (metric or imperal) from the user's configuration.
- or from the unit of the spatial reference

 At the moment it is not possible to change it on the SketchTooltipOptions directly, but this could change in an upcoming release.

In the meantime, a way to change the unit between metric and imperial is on the `view.map.portalItem`:

map.portalItem = new PortalItem({
  portal: { units: "english" }
}); 

or if portalItem already exist with instantiating from WebMap or WebScene:

map.portalItem.units = "english" 

I hope that helps.

FabricioBezerra
New Contributor II

Thanks, @SaschaBrunnerCH! It worked like a charm 👍

Note: Just noticed the portalItem "portal" property missing in the second option:

map.portalItem.portal.units = "english" 

 

snlasystem
New Contributor III

Hi,

 

We're facing a similar problem. We're working in the aviation industry so we'd like to show the tooltipOptions length unit in nautical miles instead of km and the labelOptions height in feet instead of meters. Area should still be shown in km^2.
Our map is not created from a portal item and I wasn't able to to find nautical-miles as an option in https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html#un...

Is there any workaround for this use case @SaschaBrunnerCH?