-
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
Get visible map bounding box #2571
Conversation
Guys, if you someone can guide me how to make Android version functional i will be helpful. |
@alvelig any idea? 🤗 |
@radeno man, awesome job! I had tested your fork, works brilliant! |
@Peretz30 tested both ios and android? ❤️ |
@rborn tested on Android device. iOS not tested. |
Merged with upstream. Hope will be merged. Want to add getZoom (need to investigate how to do that properly) or something like that. Than it will be easier to get visible all markers and so on. |
@alvelig 🐽 |
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.
LGTM , one question though: why does it have to be a promise? (I really don't know so I want to understand 😊)
@rborn if i understand it correct, then there are two solutions how to return a value:
Callbacks are "hell", anyways is tagged as experimental. So returned promise is awaited in javascript async function. It is transparent on JS side. |
On Google Maps, more values are available: If so, is it worth it to return them as well? I am a little bit obsessive about exposing as much of the native map helpers as possible, and wouldn't like to miss out on available data which we later cannot include for backwards-compatibility reasons, thus requiring us to add yet another helper. |
@miracle2k if have MapKit same functionality then no problem to return it. But if it's only for Google Maps then it is not multiplatform. |
@radeno MapKit does not expose those fields directly, but it might be possible to calculate them ourselves. It might also be ok to only return those fields on Android. Still, I am not even sure if those fields contain any new information; the whole thing might be nothing. Can anyone currently running this PR check? |
@miracle2k ok, let me check what google maps returns. But as naming says i except it should be for camera view, when map is skewed (not 90° angle). |
@radeno can you say, please, what is the difference between your solution and this?
|
@Peretz30
|
@Peretz30 @rborn On the other hand native calculations through my PR should takes in average 250ms on MapKit and average 150ms on Google Maps. But should be more precise. I think we should also implement helper method which takes region as argument and returns bounding box. Something like /**
* Get bounding box from region
*
* @param region Region
*
* @return Object Object bounding box ({ northEast: <LatLng>, southWest: <LatLng> })
*/
mapBoundariesForRegion(region) {
return {
northEast: {
latitude: region.latitude + region.latitudeDelta / 2,
longitude: region.longitude + region.longitudeDelta / 2,
},
southWest: {
latitude: region.latitude - region.latitudeDelta / 2,
longitude: region.longitude - region.longitudeDelta / 2,
},
};
} What do you think about it? |
@radeno I agree, but I think name of the function should be |
Note there is currently no way to get the region from the map, except via the event. I do think an imperative way to access the region, |
@miracle2k you DO think or DON'T ? |
Right now, if I ever want to use the region in calculations, I have to setup a handler for I think in many cases, where I only need to know the region in rare cases, for example when a user presses a "find button", I would think I would opt for calling |
@miracle2k ok |
@miracle2k you are right about getting bounding box without region change. I think adding helper method like |
@radeno , thanks for explanation. Now I see, your logic seems to be right and your function name suits better. |
* 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 ...
Hi, thanks for the solution...Everything was working fine (i put some markers to test both coordinates, northEast & southWest), but when i rotated the map, the markers are showed in another position...How can this be fixed? there is no support for rotation? |
Hello, im new to react-native, javascript as a whole infact. Can someone explain how to call this method. This is what i have:
I get this error back: Please help @sebackend @radeno @rborn . Thanks |
What are you trying to do with |
Use Case Approach Code
|
@rborn i believe iv found the solution. Turns out i need to use the refs prop as follows:
then i can call |
Exactly, JSX is declarative, you don't need to recreate it with |
It is still in progress. Do not merge yet. I can't build code on Android platform.
Does any other open PR do the same thing?
No
What issue is this PR fixing?
#356
How did you test this PR?
Examples: