ScaleControl
React component that wraps the base library's ScaleControl
class (Mapbox | Maplibre).
- Mapbox
- Maplibre
import * as React from 'react';
import Map, {ScaleControl} from 'react-map-gl';
function App() {
return <Map
mapboxAccessToken="<Mapbox access token>"
initialViewState={{
longitude: -100,
latitude: 40,
zoom: 3.5
}}
mapStyle="mapbox://styles/mapbox/streets-v9"
>
<ScaleControl />
</Map>;
}
import * as React from 'react';
import Map, {ScaleControl} from 'react-map-gl/maplibre';
function App() {
return <Map
initialViewState={{
longitude: -100,
latitude: 40,
zoom: 3.5
}}
mapStyle="https://api.maptiler.com/maps/streets/style.json?key=get_your_own_key"
>
<ScaleControl />
</Map>;
}
Properties
Reactive Properties
maxWidth
: string
Default: 100
The maximum length of the scale control in pixels.
style
: CSSProperties
CSS style override that applies to the control's container.
unit
: 'imperial' | 'metric' | 'nautical'
Default: 'metric'
Unit of the distance.
Other Properties
The properties in this section are not reactive. They are only used when the component first mounts.
position
: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left'
Default: 'top-right'
Placement of the control relative to the map.