maplibre-react-native
maplibre-react-native copied to clipboard
[FIX] Update fitBounds function to accept an array for padding
Description
Fixes #295
Checklist
- [X] I have tested this on a device/simulator for each compatible OS
- [X] I formatted JS and TS files with running
yarn lint:fixin the root folder - [X] I have run tests via
yarn testin the root folder - [X] I updated the documentation with running
yarn generatein the root folder - [ ] I mentioned this change in
CHANGELOG.md - [ ] I updated the typings files (
index.d.ts) - [ ] I added/updated a sample (
/example)
Screenshot OR Video
@lavi02, I think this line is good, we could even add null or undefined as an option since it isn't required, but I am not sure about the other changes.
I don't think we should remove the type from documentation. This should probably be:
| `padding` | `Number|Number[]` | `No` | Camera padding for bound |
Same with this line.
I'd prefer specifying multiple types, rather than specifying none.
Let's also keep bounds plural. "Camera padding for bounds".
@tyrauber I included animationDuration since it also can be nullable.
Can you please approve my PR? I fixed an Android release mode crash with MarkerView. This fix addresses crashes occurring in Android release mode when using MarkerView. The issue arises when updateMarkers is called while markerUpdate is still null, resulting in a NullPointerException and causing the app to crash.
@tyrauber
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[])' on a null object reference
at com.mapbox.rctmgl.components.annotation.MarkerViewManager.updateMarkers(MarkerViewManager.java:20)
at com.mapbox.rctmgl.components.mapview.RCTMGLMapView$4.onCameraMove(RCTMGLMapView.java:14)
at com.mapbox.mapboxsdk.maps.CameraChangeDispatcher.executeOnCameraMove(CameraChangeDispatcher.java:30)
at com.mapbox.mapboxsdk.maps.CameraChangeDispatcher.access$100(CameraChangeDispatcher.java)
at com.mapbox.mapboxsdk.maps.CameraChangeDispatcher$CameraChangeHandler.handleMessage(CameraChangeDispatcher.java:32)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8663)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
Thanks @lavi02, merged and in 10.0.0-alpha.6.
@lavi02 Why padding and animationDuration should be nullable? Because of null values we have typescript errors (see the screenshot).
I think correct types should be number | number[] | undefined for padding and number | undefined for animationDuration
fitBounds(
northEastCoordinates: number[],
southWestCoordinates: number[],
// no `undefined` because there is default value
padding: number | number[] = 0,
// no `undefined` because there is default value
animationDuration: number = 0.0,
): void {
@tyrauber CI didn't catch those Typescript errors?
Yeah I just saw it yesterday, will make one more pr ASAP since debounce has type error too
@lavi02 I will remove that null from types in my branch since it's ready to be merged and it's conflicting with Camera.tsx
So you could just focus on debounce (where is that exactly?)
:tada: This PR is included in version 10.0.0-beta.1 :tada:
The release is available on:
Your semantic-release bot :package::rocket: