-
-
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
Provide a camera system #2563
Provide a camera system #2563
Conversation
@miracle2k ❤️ @alvelig this LGTM and the idea is good, maybe you could have a look and add feedback? |
7a3bb53
to
5b0f156
Compare
This is now fully implemented on all three platforms, in the form I suggested, along with an example screen. I added a "deprecated" warning to all What is missing is a documentation update, which I intend to add shortly. If there are any other changes desired, please let me know. |
I believe this is now ready to be merged. It includes updated documentation, updated examples (replace use of the deprecated methods, plus a dedicated example). Also, the typescript typings have been updated. I tested all those changes on the Android and iOS emulators. @alvelig hearted the original post, so I am hopeful he is in board as well, and I'd be thrilled for him or @rborn to have a look (or another maintainer). I'd also be curious about the opinion of @techieyann, whose PR this would replace. |
LGTM @alvelig 🐽 |
@miracle2k I tried to reply to your email but your spam filter keeps rejecting me 😕 Related to this PR let's wait a little more for @alvelig and if he doesn't show not I'll merge 🤗 |
@miracle2k could you sync please ? |
Deprecate the old animateTo* methods and warn on use.
@rborn done. |
This is great, thanks @miracle2k It's working perfectly for me so far, except for when I update the heading while using mapPadding. The map rotates around the true center rather than the center I've defined with the padding. I vaguely recall this being an issue with Google Maps though, so I'll just keep using my < double height map (which makes the true center also near the bottom of the screen). One other issue is that initialCamera requires both altitude and zoom, but it's such a trivial thing I'm not sure it's necessary to fix. |
@techieyann Is there a way to make the padding issue work, natively speaking? Since both the padding and the camera are done inside Google Maps, is there something we can do to account for it? Regarding the altitude + zoom thing: Are you referring to the fact that As for the "as designed" thing - I decided to go the easy route and just represent the two distinct systems as-is, but, I suppose we could implement a conversion: Somewhere I saw Google documenting the approximate altitude for each zoom level, so I think we could use that to do a conversion if one or the other is missing. |
@miracle2k re: padding re: zoom/altitude |
* upstream/master: (28 commits) Calculate bounding box from region (react-native-maps#2615) [iOS GoogleMap] Fix animateCamera (react-native-maps#2608) Fix type definition error (react-native-maps#2607) [Android] Fix app crash in Android if building found but cannot getActiveLevelIndex (react-native-maps#2598) Provide a camera system (react-native-maps#2563) Get visible map bounding box (react-native-maps#2571) [0.22.1] Release (react-native-maps#2574) Move dev only deps to devDependencies. (react-native-maps#2548) Specify how to use Google Maps (react-native-maps#2550) r2507: remove marker: Attempt to invoke virtual method 'void com.google.android.gms.maps.model.setIcon(com.google.android.gms.maps.model.BitmapDescription)' on a null object reference #: remove marker: Attempt to invoke virtual method 'void com.google.android.gms.maps.model.setIcon(com.google.android.gms.maps.model.BitmapDescription)' on a null object reference (react-native-maps#2555) update to clarify cacheEnabled is apple maps only [0.22.0] Release (react-native-maps#2535) Fix for “The specified child already has a parent” Improve installation docs (react-native-maps#2541) fix fitToSuppliedMarkers function (react-native-maps#2524) Performance improvements for tracksViewChanges (react-native-maps#2487) fix spelling mistakes Added flag to make sure that there has an Observer of view. hotfix PR react-native-maps#2478 Fix a peer dependencies warning ...
* Add initialCamera and camera props. * Support camera and initialCamera properties on Android. * Declare camera and initialCamera properties in JS. * Add animateCamera, setCamera, getCamera on iOS/Mapkit. Deprecate the old animateTo* methods and warn on use. * Add an example for camera control. * Add animateCamera, setCamera, getCamera on iOS/GMaps. * Support setCamera, animateCamera, getCamera in Android. * Fix eslint errors. * Update documentation. * Remove use of deprecated methods from examples. * Fix crash in animateCamera() if duration not given. * Add new methods and props to TypeScript typings. * Fix bug in Android method map setup.
Does any other open PR do the same thing?
No.
What issue is this PR fixing?
There is currently no way to control the camera via props.
How did you test this PR?
I tested the example that comes with the PR on Android and on iOS with MapKit + Google Maps. I further tested the examples that have been updated as part of the PR on those platforms.
Proposal
It is currently not possible to control things like the viewing angle, or the bearing, via props. In addition, the set of imperative methods to control the camera as they exist feel to me a bit as if they have grown over time, maybe just focussing on those parts the contributor needed to solve their problem at hand.
On the other hand, both the Apple Maps SDK as well as Google Maps support a flexible powerful camera system, which we can (and should) expose more directly.
One related problem is that the new
animateToNavigation
lacks the ability to set the zoom level (#2436). The challenge there is that iOS does not support a zoom level in the way Google Maps does - it uses a meter-based altitude measurement instead.My suggestion, here (partially) implemented for Apple Maps, is as follows:
This would also allow us to deprecate most of the existing
animateTo*
methods. Whatever you need to do, you can configure the camera to the desired combination of changes.I would be willing to implement this for all platforms, but wanted to get some feedback first.
@techieyann @dorshay6 @rborn @christopherdro
Current state:
When merged, I believe this would allow us to close #2436 and #2407.