-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
[MapView] Support for annotation callouts, annotation press, callout presses and pin animation #1247
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
@dvcrn - Nice one! Sorry for the lack of love on this PR - could you possibly squash your commits and rebase against master? Thanks! |
@dvcrn excellent , this is what i am looking for :) |
@brentvatne Squashed and rebased current master |
- added didSelectAnnotationView event to MapView - only pass annotation data onAnnotationPress - added support for callouts in annotations and callout click handling - passing annotation id on annotation click - added check for MKuserLocation - added project.pbxproj changes - fixed flowtype errors - fix componentWillReceiveProps not updating annotations correctly - added option to animate pin drop - fix callouts not showing when no accessory is set - noone saw that :) - added a real identifier rather than using the annotation one - added missing type annotations
@a2 ping 😄 |
…letely re-setting them
I am working a lot with mapview lately and found some more annoyances so why not squeeze them in here as well? I updated I tried object comparison (as in Now the problem: Working on this change made me realize that the identifier system I currently have in place is a bit flawed. If the user sets his own ID, the pins will not change. If the user does not do that and relies on the auto-id I am generating, it will re-add a new ID every time the annotation array changes since it will wipe the unique-id of that annotation and generate a new one. I decided to replace the unique uuid with a hash containing a JSON.stringify representation of the annotation object. I'd love to hear some feedback on this. The good thing about this solution is, that same objects have same hashes and it is no longer random. This allows for the same pin to have the same identifier through the entire app flow, even if the user replaces the object reference with a new one (e.g. on ajax fetch). No more jumpy pins! The bad thing is, that if 2 pins are identical, the event system could fail and only 1 callback is getting executed. Though this can only happen if literally 2 pins are on the same lat, long with the same title and subtitle which... well... shouldn't happen. TODO is to base64 encode that hash, but |
This PR was imported internally but @nicklockwood had some comments. Nick, can you make those comments here? |
Thanks for the feedback, I'll try to get the stuff fixed the next days |
Awesome 😄 thanks @dvcrn |
Ok I think I got them all |
@dvcrn Hey, I think I know a workaround for the Travis CI failures. Those have nothing to do with your code changes. You have to add this line to the dependencies in
For more details, see #1546 (comment) |
Merged internally. |
* imp: Snack example for SectionList * Revert prettier mess
Split rn-tester build into debug and release
Split rn-tester build into debug and release
…ester Merge pull request facebook#1247 from rasaha91/split-rn-tester
Started from here - #1120. Most functionality for annotations were missing so I started implementing and somehow got caught up until the entire thing was done.
2 new events:
6 new properties for annotations:
1 new property for MapView
Now the important thing is, that I implemented all of this the way "I would do it". I am not sure this is the 'reacty' way so please let me know my mistakes 😄
The problem is that there is no real way to identify annotations which makes it difficult to distinguish which one got clicked. The idea is to pass a
id
and whether it has callouts the entire way with the annotation. I had to subclassMKAnnotation
for this and implemented a customRCTPointAnnotation
which addsid
,hasLeftCallout
,hasRightCallout
andanimateDrop
.I added
RCTPointAnnotation
andRCTPointAnnotationArray
into a newRCTConvert
method.The user is able to overwrite the id on the annotation directly, but if no id is set, I am generating one on
componentWillMount
orcomponentWillReceiveProps
. This id will also get passed intoonAnnotationPress
I am setting the callout accessory always to
UIButtonTypeDetailDisclosure
. Todo at some point would be to allow custom UIButtons and Images