I'm trying to get the zoom level of a map in real time to make a button that locks the zoom with the current value. I have tried using getMapZoom and getZoom but both give me an undefined value. I think I'm not using the correct ref but I haven't been able to find much documentation about it. Here's the code:
<Map className="map-layer"
center={center}
onoverlayadd={this.overlayadd}
onoverlayremove={this.overlayremove}
ondragend={this.zoomChange}
onzoomend={console.log('Zoom: ' + this.mapRef.leafletElement.getMapZoom())}
zoom={this.state.zoom}
ref={this.mapRef}
preferCanvas={false}
animate={true}
scrollWheelZoom={this.state.zoomLock ? false : true}
doubleClickZoom={this.state.zoomLock ? false : true}
touchZoom={this.state.zoomLock ? false : true}
maxZoom={7}
minZoom={7}
>
Cannot read property 'getZoom' of undefined
– Hambley