maplibre-react-native icon indicating copy to clipboard operation
maplibre-react-native copied to clipboard

[FIX] Update fitBounds function to accept an array for padding

Open lavi02 opened this issue 1 year ago • 2 comments

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:fix in the root folder
  • [X] I have run tests via yarn test in the root folder
  • [X] I updated the documentation with running yarn generate in 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 avatar Mar 26 '24 07:03 lavi02

@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 avatar May 13 '24 14:05 tyrauber

@tyrauber I included animationDuration since it also can be nullable.

lavi02 avatar May 14 '24 05:05 lavi02

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)

lavi02 avatar Jul 04 '24 06:07 lavi02

Thanks @lavi02, merged and in 10.0.0-alpha.6.

tyrauber avatar Jul 04 '24 09:07 tyrauber

@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 {

CleanShot 2024-07-11 at 21 33 57@2x

@tyrauber CI didn't catch those Typescript errors?

caspg avatar Jul 11 '24 19:07 caspg

Yeah I just saw it yesterday, will make one more pr ASAP since debounce has type error too

lavi02 avatar Jul 11 '24 22:07 lavi02

@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?)

caspg avatar Jul 12 '24 07:07 caspg

:tada: This PR is included in version 10.0.0-beta.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] avatar Dec 02 '24 11:12 github-actions[bot]