Add onPress for polygons and polylines on iOS and Android#760
Add onPress for polygons and polylines on iOS and Android#760spikebrehm merged 2 commits intoreact-native-maps:masterfrom
Conversation
|
Oh this is awesome why not merged yet? :) |
|
@felipecsl Hi, can you please take a look? 👍 |
|
Android code looks mostly good, just some nits 👍 |
felipecsl
left a comment
There was a problem hiding this comment.
Just some minor changes
| Map map = MapBuilder.of( | ||
| "onPress", MapBuilder.of("registrationName", "onPress") | ||
| ); | ||
| return map; |
There was a problem hiding this comment.
return MapBuilder.of() directly, no need to declare a variable 👍
| Map map = MapBuilder.of( | ||
| "onPress", MapBuilder.of("registrationName", "onPress") | ||
| ); | ||
| return map; |
| @Override | ||
| public void onPolygonClick(Polygon polygon) { | ||
| WritableMap event; | ||
| event = makeClickEventData(polygon.getPoints().get(0)); |
There was a problem hiding this comment.
WritableMap event = makeClickEventData(polygon.getPoints().get(0));
| @Override | ||
| public void onPolylineClick(Polyline polyline) { | ||
| WritableMap event; | ||
| event = makeClickEventData(polyline.getPoints().get(0)); |
|
Cool, android changes made. Let me know if any iOS changes are needed. I have tested this in my own applications, but not extensively. |
|
android changes look good to me. someone else should review the iOS ones (i cant :)) |
|
@felipecsl Thanks you. |
|
maybe @spikebrehm can help |
|
@spikebrehm Hi, any chance you can take a look at this? I really need this thing, thank you so much! |
|
Thanks @frankrowe, this looks good! Can you please update the example app with example usage of this feature? I'll go ahead and merge now, and if you can please follow up with another PR with the examples, I would appreciate it 🍻. |
|
Great! I will add an example as soon as I can. |
|
@frankrowe it should be used like that? I can't make it work for some reason |
|
Hey @voidale yes that is correct usage. I added examples in PR #793 can you check if that works? |
|
I installed the update from github(not npm since the version hasn't been updated) and |
…ress Add onPress for polygons and polylines on iOS and Android
Adds onPress handlers for polygons and polylines.
setOnPolygonClickListenerandsetOnPolylineClickListenerhandleMapTapand finds if the tap is inside a polygon, or if the closest polyline is within 10 pixels of the tap.