This is a React equivalent of Goong's NavigationControl, which provides zoom buttons and a compass button.
import * as React from 'react';
import ReactMapGL, {NavigationControl} from '@goongmaps/goong-map-react';
const navControlStyle= {
right: 10,
top: 10
};
function App() {
const [viewport, setViewport] = React.useState({
longitude: -122.45,
latitude: 37.78,
zoom: 14
});
return (
<ReactMapGL {...viewport} width="100vw" height="100vh" onViewportChange={setViewport}>
<NavigationControl style={navControlStyle} />
</ReactMapGL>
);
}onViewportChange (Function)Callback when the user interaction with this control requests a viewport update. If provided, will be called instead of the containing InteractiveMap's onViewportChange.
showCompass (Boolean)trueShow or hide the compass button
showZoom (Boolean)trueShow or hide the zoom buttons
zoomInLabel (String)Zoom InLabel applied to the zoom in control button.
zoomOutLabel (String)Zoom OutLabel applied to the zoom out control button.
compassLabel (String)Reset NorthLabel applied to the compass control button.
className (String)Assign a custom class name to the container of this control.
style (Object){position: 'absolute'}A React style object applied to this control.
captureScroll (Boolean)falseStop propagation of mouse wheel event to the map component. Can be used to stop map from zooming when this component is scrolled.
captureDrag (Boolean)trueStop propagation of dragstart event to the map component. Can be used to stop map from panning when this component is dragged.
captureClick (Boolean)trueStop propagation of click event to the map component. Can be used to stop map from calling the onClick callback when this component is clicked.
captureDoubleClick (Boolean)trueStop propagation of dblclick event to the map component. Can be used to stop map from zooming when this component is double clicked.
capturePointerMove (Boolean)falseStop propagation of pointermove event to the map component. Can be used to stop map from calling the onMouseMove or onTouchMove callback when this component is hovered.
Like its Goong counterpart, this control relies on the goong-js stylesheet to work properly. Make sure to add the stylesheet to your page.