ScaleContro
Scale component, used to display the ratio between distance on the map and the actual distance.
Example
Example Source Code
tsx
import React, { useState } from 'react'
import ReactDOM from 'react-dom'
import { MbMap, MbScaleControl, MbTiandituLayer } from '@mapbox-react/core'
const App = () => {
const [mapCenter] = useState([116.38745, 39.91266])
const [zoom, setZoom] = useState(2)
return (
<div className="map-wrapper">
<MbMap center={mapCenter} zoom={zoom}>
<MbTiandituLayer types={['vec']} />
<MbScaleControl position="bottom-right" />
</MbMap>
</div>
)
}
ReactDOM.render(<App />, document.querySelector('#root'))
API
PROPS
Name | Description | Type | Default |
---|---|---|---|
position | Position | string('top-left' , 'top-right' , 'bottom-left' ,'bottom-right') | top-right |
maxWidth | Maximum length of the ScaleControl, in pixels | number | 100 |
unit | Unit | string('imperial' , 'metric' , 'nautical') | metric |
EVENTS
Name | Description | Parameters |
---|---|---|
onCreated | Map initialization completed event | - |
METHODS
Name | Description | Definition |
---|