react-map-gl icon indicating copy to clipboard operation
react-map-gl copied to clipboard

How to get current zoom level of the map?

Open lymine1996 opened this issue 4 years ago • 2 comments

What I need to do is to deactivate the highlight function until the users reach a certain higher zoom level. So is there a getZoom() function in this library and how to apply it? I'm confused since every answer on StackOverflow is about react-mapbox-gl but I don't have time to switch the whole codebase.

lymine1996 avatar Jul 25 '21 22:07 lymine1996

You can try using the "onZoom", in the object you'll see the zoom <ReactMapGL {...viewport} onZoom={(e) => { console.log(e.viewState.zoom); }} >

amirbashan avatar Feb 27 '22 11:02 amirbashan

the method you're looking for is onViewStateChange

 <ReactMapGL {...viewport} onViewStateChange={(e) => { console.log(e.viewState.zoom); }} >

quickshiftin avatar Feb 25 '23 22:02 quickshiftin