-
-
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
Added animateToNavigation method to MapView #2049
Conversation
Great contribution! But could you add an example to the project please? |
Thanks! Actually I do have. I needed that new method for an actual project so i've made a testing one which can be found here. The use of the method itself is at NavigationMap.js, line 77. |
Please undo c819f45 and add an example here please. |
8734bae
to
1063872
Compare
@guilhermeed thanks for this contribution, I tested it on android - it works, but it behaves weird if you set mapPadding. If you want the marker a little bit closer to the bottom, like navigation apps do, for example. Maybe you could add an additional parameter that allows the function to set a vertical offset that allows the current location to be centered towards the bottom of the screen instead of the middle |
LGTM @rborn @christopherdro 🐽 |
@juergengunz What a great idea! I'll see what i can do. |
Hey guys. I'm having trouble calculating the offset at AirMapView.java, lines 590-605. If you could take a look at my algorithm that would be great. I commented it so you could check it out. |
@guilhermeed nice! Check out this comment, he made an example for iOS and this seems to work. Maybe you could just adapt the algorithm for android. |
@guilhermeed what is the Wouldn't it be better to have this alignment stuff be relative to the map zoom (or lat/long delta)? Ideally this just looks at the coordinates of the edge of the screen to align the user's center point to the bottom of the screen (maybe with an inset). Better to ship this without the offset logic for now ? |
@EricPKerr The offset should be the distance from the current location to the bottom of the map. For instance, most of the navigation apps out there shows the driver position not at the center of the map, but a little to the bottom, instead. |
I've been watching this for the past month and a half, super excited for it to land. I think the offset is not super necessary, I'd mostly just love to be able to set the angle and bearing at the same time. Thanks for your work, hope I get to use it soon! |
I have already used this functionality in one of my projects and the offset wasn't much of a must-have in this case because most of the time i needed to display some info at the bottom of the screen (which overlapped the bottom part of the map). |
@guilhermeed yeah 🤗 |
There you go :) |
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.
- please remove all IDE config files from the commit (like
.project
,.vscode
) - there are a lot of new
X.class
files comitted, do we need them?
@@ -332,14 +345,15 @@ public Map getExportedCustomDirectEventTypeConstants() { | |||
@Nullable | |||
@Override | |||
public Map<String, Integer> getCommandsMap() { | |||
Map<String, Integer> map = MapBuilder.of( | |||
Map<String, Integer> map = this.CreateMap( |
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.
Why this? CreateMap
looks to me now very unreadable and limiting (only 8 key/values pairs allowed and ambiguous naming -> k1,v1
)
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.
Hey @rborn sorry about the delay. It's been very hard for me to dedicate time for this. Now about "CreateMap". I was going to ask you guys about the MapBuilder. I have noticed you were using the MapBuilder from com.facebook.react.common.MapBuilder; but if you take a look at it here you'll see it's limitating as well. It seems the MapBuilder class only supports up to 7 keys and I needed 8 (the naming i used was similar to what you'll find in the MapBuilder class). Of course this is not the ideal solution, but I wasn't able to find a solution around it back then.
@guilhermeed added few comments 🤗 |
Gonna be so excited when this lands. |
Any update here? |
@rborn I've deletes the IDE and .class files as you asked. Do you think there is something else that needs to be done? If you have a good solution for the Map function that we've discussed above that would be great as well. |
@rborn Is there anything I can do to get this through? |
@alvelig need some help here, can you take a look? 🐽 |
@rborn I am! Thanks for the reminder! LGTM |
@alvelig Tested and works for me. |
Can i pass a object with all my pins locations to it? like in fitToCoordinates(objectWithLocations) ? |
How to focus map on the current location while using animateToNavigation? In the example also map position is fixed. Can anyone help? |
I've been waiting on this functionality, I even wrote my own version for Android but didn't get around to the iOS code. Thank you so much! Why is there no zoom parameter though? I know most of the package uses regions which negates the need for zoom, but this function just uses a center. It's just one number passed down to the GoogleMap API. @jonathanmauer No, this merge is just the animateToNavigation function. @ayushnawani It's up to you to supply the lat/long of where you want the map to be. It sounds like you need to access the GPS of your device and then pass the location results to the function. |
* master: (168 commits) Adding overlaying components details (react-native-maps#2425) docs: pin color limitations for android (react-native-maps#2429) Revert "Added MBTiles support for iOS and Android (react-native-maps#2208)" (react-native-maps#2387) Added MBTiles support for iOS and Android (react-native-maps#2208) Fix disabling the toolbar and my location button (react-native-maps#2317) Fixes warnings about self (react-native-maps#2341) Android: Fix lineCap of Polyline (react-native-maps#2375) Update installation.md (react-native-maps#2381) update doc (react-native-maps#2363) zIndex doesn't work when the map moves in iOS 11 (react-native-maps#2359) Fix readme formatting (react-native-maps#2358) add support for calloutAnchor with GoogleMaps on iOS; fixes react-native-maps#1852 (react-native-maps#2351) Added animateToNavigation method to MapView (react-native-maps#2049) Add react-native@^0.55 to peerDependencies (react-native-maps#2332) Fix custom marker updates on android react-native-maps#1611 react-native-maps#2048 [iOS] Prefix or eliminate globals in AIRMapMarker (react-native-maps#2306) Fix CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF warnings (react-native-maps#2154) Fix for compile error (react-native-maps#2215). (react-native-maps#2232) Make tiles display at the same physical size regardless of pixel dens… (react-native-maps#2248) Added support of lineDashPattern polyline prop to iOS Google Maps (react-native-maps#2243) ... # Conflicts: # lib/components/MapMarker.js
* added animateToNavigation method to MapView * Added AnimatedNavigation example * Updated Fork * Deleted IDE files and Unnecessary .class files
* added animateToNavigation method to MapView * Added AnimatedNavigation example * Updated Fork * Deleted IDE files and Unnecessary .class files
animateToNavigation is a method to allow navigation-like moviment to a map that, for instance, follows the user position. (like google maps navigation or waze).
On android when trying to animateToRegion, animateToBearing and animateToViewingAngle simultaniously the methods would overwride each other's movement. animateToNavigation solves this problem.
CreateMap method is introduced to solve the react's MapBuilder limitation of key-value pairs.
This was already tested worked on android.