NavigationControl
Navigation controls component, including zoom buttons and a compass.
Example
Example Source Code
tsx
import React, { useState } from 'react'
import ReactDOM from 'react-dom'
import { MbMap, MbNavigationControl, 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']} />
<MbNavigationControl position="top-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 |
showCompass | Is compass visible | boolean | true |
showZoom | Is zoomer visible | boolean | true |
EVENTS
Name | Description | Parameters |
---|---|---|
onCreated | Map initialization completed event | - |
METHODS
Name | Description | Definition |
---|