You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importReact,{useRef,useEffect,useState}from'react';importMapbox,{MapView,Camera,CustomLocationProvider,LocationPuck,Viewport}from'@rnmapbox/maps';import{Icon}from'react-native-elements';exportdefaultfunctionBugReportExample(){const[style,setStyle]=useState('mapbox://styles/mapbox/streets-v11');const[bearing,setBearing]=useState(0);const[location,setLocation]=useState([-74.00597,40.71427]);const[prevLocation,setPrevLocation]=useState<number[]|null>(null);constviewportRef=useRef<Viewport|null>(null);// Bearing calculation functionfunctioncalculateBearing(lat1,lon1,lat2,lon2){constradLat1=(lat1*Math.PI)/180;constradLat2=(lat2*Math.PI)/180;constdeltaLon=((lon2-lon1)*Math.PI)/180;consty=Math.sin(deltaLon)*Math.cos(radLat2);constx=Math.cos(radLat1)*Math.sin(radLat2)-Math.sin(radLat1)*Math.cos(radLat2)*Math.cos(deltaLon);constbearing=(Math.atan2(y,x)*180)/Math.PI;return(bearing+360)%360;}useEffect(()=>{constinterval=setInterval(()=>{setLocation(location=>{// Calculate the bearing if prevLocation existsif(prevLocation){constnewBearing=calculateBearing(prevLocation[1],prevLocation[0],location[1]+0.0001,location[0]+0.0001);setBearing(newBearing);}constnewLocation=[location[0]+0.0001,location[1]+0.0001];// Update prevLocation with the current location before it changessetPrevLocation(location);returnnewLocation;});},500);return()=>clearInterval(interval);},[prevLocation]);return(<><MapViewstyle={{flex: 1}}onDidFinishLoadingStyle={()=>{viewportRef.current?.transitionTo({kind: 'followPuck'},{kind: 'default'});}}styleURL={style}><Mapbox.Imagesimages={{userLocationTopImage: "<path to image>",}}/><CameradefaultSettings={{centerCoordinate: [-74.00597,40.71427],zoomLevel: 14,}}followZoomLevel={14}followUserLocation={true}/><Viewportref={viewportRef}/><CustomLocationProvidercoordinate={location}heading={bearing}/><LocationPuckvisible={true}puckBearingEnabled={true}topImage={'userLocationTopImage'}scale={['interpolate',['linear'],['zoom'],10.0,1.0,20.0,2.0]}/></MapView><IcononPress={()=>{setStyle(style==='mapbox://styles/mapbox/streets-v11'
? 'mapbox://styles/mapbox/satellite-v9'
: 'mapbox://styles/mapbox/streets-v11');}}containerStyle={{position: 'absolute',bottom: 10,right: 0,}}raisedname='layers'type='material'color={'black'}/></>);}
Observed behavior and steps to reproduce
There is a bug with <LocationPuck />. It works perfectly fine on Android devices but on iOS the topImage is flipped on initial load. When I change the map style the image again flips and the scale is off.
iOS Device is on the left
Android Device is on the right
My.Movie.1.mp4
Expected behavior
No response
Notes / preliminary analysis
No response
Additional links and references
No response
The text was updated successfully, but these errors were encountered:
Mapbox Implementation
Mapbox
Mapbox Version
default
React Native Version
0.71.8
Platform
iOS
@rnmapbox/maps
version10.1.19
Standalone component to reproduce
Observed behavior and steps to reproduce
There is a bug with
<LocationPuck />
. It works perfectly fine on Android devices but on iOS thetopImage
is flipped on initial load. When I change the map style the image again flips and the scale is off.iOS Device is on the left
Android Device is on the right
My.Movie.1.mp4
Expected behavior
No response
Notes / preliminary analysis
No response
Additional links and references
No response
The text was updated successfully, but these errors were encountered: