Skip to content
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

camera fitBounds adds padding every time it is called on android #956

Closed
cedriclinares opened this issue Jul 13, 2020 · 9 comments · Fixed by #973
Closed

camera fitBounds adds padding every time it is called on android #956

cedriclinares opened this issue Jul 13, 2020 · 9 comments · Fixed by #973
Labels
bug 🪲 Something isn't working

Comments

@cedriclinares
Copy link

cedriclinares commented Jul 13, 2020

Describe the bug
When calling this.map.fitBounds(ne, sw, padding, duration) the map adds padding everytime it is called ultimately leading to an error "Unable to calculate appropriate zoom level for bounds. Vertical or Horizontal padding is greater than map's height or width"
To Reproduce
Steps to reproduce the behavior.
Run page on android
Press button to set bounds multiple times
camera will add padding until error occurs

Example:

import React from 'react';
import { Text, TouchableOpacity, View } from 'react-native';
import {
  MapView,
  ShapeSource,
  LineLayer,
  Camera,
} from '@react-native-mapbox-gl/maps';

class BugReportExample extends React.Component {

setCameraBounds() {
   this.camera.fitBounds(
        [-73.962734, 40.803432],
        [-73.966600, 40.760261],
        50,
        1000
      )
}

  render() {
    return (
     <View style={{ width: '100%', height: '100%' }}>
         <TouchableOpacity
            onPress={() => {
              this.setCameraBounds();
            }}
            style={{ height: 25, width: '100%', backgroundColor: 'blue' }}
          >
            <Text style={{ color: 'white' }}>Fit Bounds</Text>
          </TouchableOpacity>
          <MapboxGL.MapView
            ref={ref => this.map = ref}
            style={{flex: 1}}
          >
            <MapboxGL.Camera
              ref={ref => this.camera=ref}
              zoomLevel={16}
            />
          </MapboxGL.MapView>
      </View>
    );
  }
}

**Expected behavior**
It should fit bounds with appropriate padding

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Versions (please complete the following information):**
 - Platform: Android
 - Device: Samsung Galaxy S9
 - Emulator/ Simulator: no
 - OS: Android 10
 - react-native-mapbox-gl: master
 - React Native Version 0.61.5

**Additional context**
It was working not so long ago but now the same behavior occur even after reinstalling node modules.
@ferdicus
Copy link
Member

Please clean up the ticket.
Thanks

@sunny-lirr
Copy link

This is the result of #941 which tried to fix the padding on fitBounds (#841) but seems to be adding it to existing padding instead of replacing it.

@mfazekas
Copy link
Contributor

I've added a fix with #973.

It can be tested with

npm i mfazekas:maps1#mfazekas/fix-padding-android-add

@luskin
Copy link

luskin commented Aug 24, 2020

@mfazekas we are still receiving this error constantly on 8.1.0-rc.2 - any advice?

@mfazekas
Copy link
Contributor

@luskin can you try master?!

@luskin
Copy link

luskin commented Aug 24, 2020

@mfazekas - yes, adding master worked. Any timeline for creating an official release with this?

@naftalibeder
Copy link
Collaborator

@luskin @mfazekas So which version has this working? Are you just pointing to the latest commit from master? We've also been getting this error when trying to upgrade, and would be interested in an official release as well.

@luskin
Copy link

luskin commented Aug 31, 2020

@naftalibeder: "@react-native-mapbox-gl/maps": "https://github.com/react-native-mapbox-gl/maps#master",

@naftalibeder
Copy link
Collaborator

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants