0
votes

I am trying to implement imperial (miles) on a react Mapbox map scale. I have been going off of this documentation: https://docs.mapbox.com/mapbox-gl-js/api/, and have tried both but neither works:

                    <ReactMapboxGL
                        imperial={true}
                    >

and

                    <ReactMapboxGL
                    unit={"imperial}
                    >

Has anyone ever successfully switched from km to mi in the bottom scale?

1

1 Answers

2
votes

According to the documentation, the units need to be set in the ScaleControl object.

Look at this example from the docs:

var scale = new mapboxgl.ScaleControl({
  maxWidth: 80,
  unit: 'imperial'
});

map.addControl(scale);

scale.setUnit('metric');