-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add onPress for polygons and polylines on iOS and Android #760
Add onPress for polygons and polylines on iOS and Android #760
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 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some minor changes
Map map = MapBuilder.of( | ||
"onPress", MapBuilder.of("registrationName", "onPress") | ||
); | ||
return map; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return MapBuilder.of()
directly, no need to declare a variable 👍
Map map = MapBuilder.of( | ||
"onPress", MapBuilder.of("registrationName", "onPress") | ||
); | ||
return map; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
@Override | ||
public void onPolygonClick(Polygon polygon) { | ||
WritableMap event; | ||
event = makeClickEventData(polygon.getPoints().get(0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WritableMap event = makeClickEventData(polygon.getPoints().get(0));
@Override | ||
public void onPolylineClick(Polyline polyline) { | ||
WritableMap event; | ||
event = makeClickEventData(polyline.getPoints().get(0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
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 |
Adds onPress handlers for polygons and polylines.
setOnPolygonClickListener
andsetOnPolylineClickListener
handleMapTap
and finds if the tap is inside a polygon, or if the closest polyline is within 10 pixels of the tap.