chrisdrackett / react-mapkit

React wrapper for Apple's mapkit.js.
https://chrisdrackett.github.io/react-mapkit/?selectedStory=all%20props&full=0&addons=1&stories=1&panelRight=1&addonPanel=storybooks%2Fstorybook-addon-knobs
MIT License
76 stars 26 forks source link

add hooks for event handling #6

Closed chrisdrackett closed 5 years ago

chrisdrackett commented 6 years ago

https://developer.apple.com/documentation/mapkitjs/mapkit/map/handling_map_events

torrao commented 6 years ago

@chrisdrackett

how are planing of exposing the different events handlers?

Invoke like this:

<MapKit regionChangeStartEventHandler={(event) => console.log("Region Change Started");}

and then adding it to the map on updateMapProps?

if (this.props.regionChangeStartEvent) {
    this.map.addEventListener("region-change-start", this.props.regionChangeStartEvent);
}
chrisdrackett commented 6 years ago

yeah, I think this is probably the best way to go. I was thinking of using language along the lines of onRegionChangeStart to fit with other events in react.

chrisdrackett commented 5 years ago

I'm redoing this as a hook that provides the map object directly. This way users can use the map to add or remove event listeners themselves.