Replies: 31 comments 2 replies
-
inspecting the code i've found following
wouldn't it make sense to at least provide possibility to pass |
Beta Was this translation helpful? Give feedback.
-
hey @nasmuris, sounds reasonable to me - would you be willing to open a PR for this? |
Beta Was this translation helpful? Give feedback.
-
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Beta Was this translation helpful? Give feedback.
-
I'd say this is a particularly important feature right now because in order for UserLocation renderMode to be native on android, Camera followUserLocation must be true, but if followUserLocation is true, setCamera can't be used! Can we reopen? |
Beta Was this translation helpful? Give feedback.
-
Right, I believe that is the current status on setCamera. I'm wondering if we can get it consistent with how the iOS version works? |
Beta Was this translation helpful? Give feedback.
-
I'll reopen this - and yes, would be great if someone could take a jab at this. |
Beta Was this translation helpful? Give feedback.
-
as a workaround for not being able to use
|
Beta Was this translation helpful? Give feedback.
-
Same issue here, as a workaround could you please give an example how to use these attributes ?, I have navigation mode map which use followUserLocation, if user moved the map and clicked on center button I want to get back to current location. @ferdicus |
Beta Was this translation helpful? Give feedback.
-
Not sure if this would help in your case, but I currently set import React, {useState, useEffect, useRef} from 'react';
import {Platform, View} from 'react-native';
import MapboxGL from '@react-native-mapbox-gl/maps';
...
export default function MapScreen(props) {
const cameraRef = useRef();
const [followUser, setFollowUser] = useState(Platform.OS === 'android');
useEffect(() => {
if (!followUser && cameraRef?.current) {
cameraRef.current.moveTo([-3.0886, 54.539627], 300);
}
}, [followUser]);
return (
<View style={styles.container}>
<MapboxGL.MapView
style={styles.map}
styleURL={STYLE_URL}
onDidFinishLoadingStyle={() => {
if (followUser) {
// Required for Android heading indicator,
// triggers effect to focus camera on init values
setFollowUser(false);
}
}}>
<MapboxGL.Camera
ref={cameraRef}
// native for Android, only works if followUserLocation set to true
followUserLocation={followUser}
zoomLevel={11}
centerCoordinate={[-3.0886, 54.539627]}
animationMode={'flyTo'}
animationDuration={1900}
/>
<MapboxGL.UserLocation
visible={true}
renderMode={'native'}
// Android indicator set via androidRenderMode
showsUserHeadingIndicator={Platform.OS === 'ios'}
// native/android only render mode (compass: triangle with heading)
androidRenderMode={'compass'}
/>
</MapboxGL.MapView>
</View>
);
} |
Beta Was this translation helpful? Give feedback.
-
This is not an issue - please refer to the gitter chat/ stackoverflow or Discussions for usage advise |
Beta Was this translation helpful? Give feedback.
-
@ferdicus Sorry for being unable to reply for such a long time, but this bug/feature had low prio for my project and I haven't had enought time to dig into this in my free time... |
Beta Was this translation helpful? Give feedback.
-
Same problem here. I'm trying to change the pitch based on the navigation mode but the problem is that when the user location updates at the same time the camera's animation stops. |
Beta Was this translation helpful? Give feedback.
-
This also seem to affect camera.flyTo as well as changing the centerCoordinate dynamically using a state. When followUserLocation is set to true, both dont work, but if false, it works fine. |
Beta Was this translation helpful? Give feedback.
-
@gokugen - did you try |
Beta Was this translation helpful? Give feedback.
-
@ferdicus yes even with |
Beta Was this translation helpful? Give feedback.
-
Hi stale bot, so in your mind, things without activity are fixed? Robots... |
Beta Was this translation helpful? Give feedback.
-
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Beta Was this translation helpful? Give feedback.
-
Activity is happening. |
Beta Was this translation helpful? Give feedback.
-
is there a workaround for this yet? I can't have followUser but also flyTo? |
Beta Was this translation helpful? Give feedback.
-
Also experiencing this and a solution in the api would be much appreciated (something like the const [coordinates, setCoordinates] = useState<Coordinates>(null)
const [followUserLocation, setFollowUserLocation] = useState<boolean>(true)
const flyTo = (coordinates: Coordinates) => {
setFollowUserLocation(false)
setCoordinates(coordinates)
}
useEffect(() => {
if (!followUserLocation && coordinates) {
cameraRef.current.flyTo(coordinates)
}
}, [followUserLocation, coordinates])
... |
Beta Was this translation helpful? Give feedback.
-
Has anybody been able to find a solution to this issue? I’m having it on Android (only when targeting Android 12 for some reason). Same code working on iOS without issues even if followUserLocation is set to true. My environment: |
Beta Was this translation helpful? Give feedback.
-
Activity is happening |
Beta Was this translation helpful? Give feedback.
-
I understand that you people might think that it doesn't make sense to allow a setCamera, moveTo or flyTo operation to be performed when the user wants the map to follow location, but there are a bunch of cases where you wanna change some camera properties without the need to turn off followUserLocation, just to turn it back on once the camera change has been performed. Plus, on iOS, this is not happening, and PLEASE don't change that 😅. I mean, I might want to change the zoom, the pinch and other properties, and I cannot do anything like that without this on/off, which sucks because I need to trigger a rerender uselessly... Are you sure it makes sense to keep it that way? |
Beta Was this translation helpful? Give feedback.
-
@whiteHatCip But it's not clear how Zoom, pitch etc can be changed with changing |
Beta Was this translation helpful? Give feedback.
-
The problem is that I start my application with the followUserLocation set to true, then the new coordinates for the current location arrive, but the camera doesn't move on it's own to the current location, and specifically with the desired zoom level, to say one example. This thing is not a problem on iOS, why should it be on Android? |
Beta Was this translation helpful? Give feedback.
-
Agreeing with @whiteHatCip here. In order to achieve a moveTo if followUserLocation is set to true we have to use this workaround: #1079 (comment) |
Beta Was this translation helpful? Give feedback.
-
@steffenkleinle If I may add another consideration about the workaround, you have to always make sure that the condition to perform the move/fly to coordinates is always correct, meaning that if you don't want to flit, you have to make sure that in the #1079 (comment) workaround the |
Beta Was this translation helpful? Give feedback.
-
any updates? Is there a way to check if moveTo/flyTo got "completed"? setting |
Beta Was this translation helpful? Give feedback.
-
I think React is getting in the way in this particular case. Scenario:
Camera follows user location. All is well. Next, user performs some action that requires moving camera to another location (taps a button, enters search, etc). We want to stop following user location and move the camera:
Problem: nothing happens. The |
Beta Was this translation helpful? Give feedback.
-
@mfazekas My expected behavior is:
Right now, this is my "Locate me" method:
Any help on how to solve this would be appreciated. In this video you can see clearly what happens if I try pressing the compass. I was pressing it in each second so you can see the different behaviors. It keeps snapping back, it's not maintaining its NORTH orientation. compass.mp4 |
Beta Was this translation helpful? Give feedback.
-
Describe the bug
setCamera doesn't take effect if followUserLocation set to true
To Reproduce
set Camera's component
followUserLocation
prop to true and try to callsetCamera
on it's refExample:
Expected behavior
it should be possible to setCamera or at least some of it's props in case followUserLocation===true
while i see there can be some conflict updating the coords (which one should be prioritized?) at least zoomLevel, pitch and rotation should be just fine
Screenshots
Versions (please complete the following information):
Beta Was this translation helpful? Give feedback.
All reactions