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,{useState,useEffect}from'react';import{Alert}from'react-native';importMapboxfrom'@rnmapbox/maps';import{ButtonGroup}from'@rneui/base';constShowMap=()=>{useEffect(()=>{Mapbox.locationManager.start();return(): void=>{Mapbox.locationManager.stop();};},[]);constonMapChange=(index: number,newStyleURL: Mapbox.StyleURL): void=>{};constonUserMarkerPress=(): void=>{Alert.alert('You pressed on the user location annotation');};return(<><Mapbox.MapViewtestID={'show-map'}onMapIdle={()=>{console.debug('======> onMapIdle');}}onCameraChanged={()=>{console.debug('======> onCameraChanged');}}><Mapbox.CamerafollowZoomLevel={12}followUserLocationanimationDuration={0}/><Mapbox.UserLocationonPress={onUserMarkerPress}/></Mapbox.MapView></>);};exportdefaultShowMap;
Observed behavior and steps to reproduce
When the device is offline, onMapIdle method is not being triggered as expected.
Steps to repro
Run the example app, replace the ShowMap.tsx file with the above code. Just add the console logs as mentioned
Go offline and run the app.
Open the ShowMap screen, try changing the layer.
Pan the map and check for the logs
iOS
Screen.Recording.2024-12-04.at.16.36.22.mov
Android
Screen.Recording.2024-12-04.at.16.28.03.mp4
Expected behavior
onMapIdle should fire while being offline. It does fires when the device is online.
Notes / preliminary analysis
Most likely due to the SDK not able to fetch the tiles successfully, in turn not triggering the onMapIdle
Additional links and references
No response
Full Code
importReact,{useState,useEffect}from'react';import{Alert}from'react-native';importMapboxfrom'@rnmapbox/maps';import{ButtonGroup}from'@rneui/base';importsheetfrom'../../styles/sheet';import{onSortOptions}from'../../utils';import{ExampleWithMetadata}from'../common/ExampleMetadata';// exclude-from-docconstShowMap=()=>{const_mapOptions=Object.keys(Mapbox.StyleURL).map((key)=>{return{label: key,data: (Mapbox.StyleURLasany)[key],// bad any, because enums};}).sort(onSortOptions);const[styleURL,setStyleURL]=useState({styleURL: _mapOptions[0].data});useEffect(()=>{Mapbox.locationManager.start();return(): void=>{Mapbox.locationManager.stop();};},[]);constonMapChange=(index: number,newStyleURL: Mapbox.StyleURL): void=>{setStyleURL({styleURL: newStyleURL});};constonUserMarkerPress=(): void=>{Alert.alert('You pressed on the user location annotation');};return(<><ButtonGroupbuttons={_mapOptions.map((i)=>i.label)}selectedIndex={_mapOptions.findIndex((i)=>i.data===styleURL.styleURL,)}onPress={(index)=>onMapChange(index,_mapOptions[index].data)}/><Mapbox.MapViewstyleURL={styleURL.styleURL}style={sheet.matchParent}testID={'show-map'}onMapIdle={()=>{console.debug('======> onMapIdle');}}onCameraChanged={()=>{console.debug('======> onCameraChanged');}}><Mapbox.CamerafollowZoomLevel={12}followUserLocationanimationDuration={0}/><Mapbox.UserLocationonPress={onUserMarkerPress}/></Mapbox.MapView></>);};exportdefaultShowMap;/* end-example-doc */constmetadata: ExampleWithMetadata['metadata']={title: 'Show Map',tags: ['Camera#followZoomLevel','UserLocation#onPress'],docs: `Shows a map with the user location annotation enabled, and on press of the user location annotation, an alert is shown.`,};ShowMap.metadata=metadata;
The text was updated successfully, but these errors were encountered:
Mapbox Implementation
Mapbox
Mapbox Version
11.8.0
React Native Version
0.75.x
Platform
iOS, Android
@rnmapbox/maps
version#main
Standalone component to reproduce
example/ShowMap.tsx
Observed behavior and steps to reproduce
When the device is offline,
onMapIdle
method is not being triggered as expected.Steps to repro
iOS
Screen.Recording.2024-12-04.at.16.36.22.mov
Android
Screen.Recording.2024-12-04.at.16.28.03.mp4
Expected behavior
onMapIdle
should fire while being offline. It does fires when the device is online.Notes / preliminary analysis
Most likely due to the SDK not able to fetch the tiles successfully, in turn not triggering the
onMapIdle
Additional links and references
No response
Full Code
The text was updated successfully, but these errors were encountered: