How to show South African measurements in a scale bar?

394
2
06-15-2021 02:40 AM
SiyabongaKubeka
Occasional Contributor

Hi All

I am using a scalebar in my map to show zoom in/out level. Currently it is showing mi which I presume it stands for miles and ft which I presume it stands for feet. I am based in South Africa and I need to use the metric system how do I do that?

ScaleBar code:

var scaleBar = new ScaleBar({
view: view
});
// Add widget to the bottom left corner of the view
view.ui.add(scaleBar, {
position: "bottom-left"
});

This how it currently show

SiyabongaKubeka_0-1623749857187.png

and

SiyabongaKubeka_2-1623749955085.png

 

Kind Regards

Siyabonga Kubeka

 

 

Tags (3)
0 Kudos
2 Replies
ThomasHoman
Occasional Contributor

Hello,

Take a look at the API reference for ScaleBar https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ScaleBar.html#style There appears to be a unit value where a metric display can be specified.

Thus your sample code becomes

var scaleBar = new ScaleBar({
view: view,

unit: "metric"
});
// Add widget to the bottom left corner of the view
view.ui.add(scaleBar, {
position: "bottom-left"
});

I cannot get access to the Javascript sandbox this morning to test. https://developers.arcgis.com/javascript/3/sandbox/sandbox.html?sample=map_simple so hopefully I have the syntax correct.

Regards,

Tom

0 Kudos
DarrenDe_Lange
New Contributor III

Hwzit

Not sure if this helps below: 

# Create scale bar
scalebar = ScaleBar(0.08, "cm", length_fraction=0.25)
ax.add_artist(scalebar)

 

Found on: https://pypi.org/project/matplotlib-scalebar/

0 Kudos