maps: zoomTo does not work after upgrading from version 8.3.0 to 8.4.0

Describe the bug

zoomTo does not work after upgrading from version 8.3.0 to 8.4.0

To Reproduce

import React, { memo, useCallback } from 'react';
import { TouchableOpacity, Text } from 'react-native';
import MapboxGL from '@react-native-mapbox-gl/maps';

const Test = () => {
  const camera = React.createRef(null);
  const map = React.createRef(null);
  const zoom = useCallback(
    async (zoomIn) => {
      const currentZoom = await map.current.getZoom();
      camera.current.zoomTo(currentZoom + (zoomIn ? 1 : -1));
    },
    [map, camera]
  );
  const zoomPlus = useCallback(() => zoom(true), [zoom]);
  const zoomMinus = useCallback(() => zoom(), [zoom]);
  return (
    <>
      <MapboxGL.MapView style={styles.map} ref={map}>
        <MapboxGL.Camera ref={camera} />
      </MapboxGL.MapView>
      <TouchableOpacity onPress={zoomPlus}>
        <Text>zoom plus</Text>
      </TouchableOpacity>
      <TouchableOpacity onPress={zoomMinus}>
        <Text>zoom minus</Text>
      </TouchableOpacity>
    </>
  );
};

Versions

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 5
  • Comments: 21 (14 by maintainers)

Most upvoted comments

@ferdicus, zoomTo from master still doesn’t work, but setCamera with centerCoordinate property does. @ShepelE, thx 😉