react-native-mapsforge-vtm
Version:
React Native components to build vector maps using Mapsforges fork of vtm. Offline rendering of OpenStreetMap data. Android only
31 lines (28 loc) • 720 B
JavaScript
;
/**
* External dependencies
*/
import { isFunction } from 'lodash-es';
import { useEffect } from 'react';
import { NativeEventEmitter } from 'react-native';
/**
* Internal dependencies
*/
const useMapEvents = ({
nativeNodeHandle,
onMapEvent
}) => {
useEffect(() => {
const eventEmitter = new NativeEventEmitter();
let eventListener = eventEmitter.addListener('onMapEvent', response => {
if (response.nativeNodeHandle === nativeNodeHandle && isFunction(onMapEvent)) {
onMapEvent(response);
}
});
return () => {
eventListener.remove();
};
}, [nativeNodeHandle, onMapEvent]);
};
export default useMapEvents;
//# sourceMappingURL=useMapEvents.js.map