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

My map reset to user location #4987

Open
DETLIXX opened this issue Feb 26, 2024 · 2 comments
Open

My map reset to user location #4987

DETLIXX opened this issue Feb 26, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@DETLIXX
Copy link

DETLIXX commented Feb 26, 2024

Summary

Hello, i am working on map where i have some pins, and when i click on pins it open bottomsheet. Problem is, that when i click on any marker it reset position, or when i close bottomsheet that has nothing to do with map it reset again on user location. My code is long and in many components so i cant show you everythig but i will show u how Map and Marker works

Reproducible sample code

<MapView 
          showsPointsOfInterest={false} 
          ref={mapRef} 
          showsUserLocation
          followsUserLocation={true} 
          containerHeight={'50%'} 
          style={{flex: 1}} 
          showsTraffic
          initialRegion={initialRegion}>

          {waypointLocation ? <DestinationMarkDirection/> : null}

          <EventLocationGenerator events={events}/>

          {/* Map legend show all icons like gas stations, shop etc */}
          <MapLegend spots={spots}/> 
        </MapView>
  )


    return (
        spots.map((res, index) =>  { 
            const cords = {latitude: res.address.latitude, longitude: res.address.longitude}
            return ( 
            <Marker
                onPress={() => handleMarkClick(res._id)}
                key={index}
                coordinate={cords} >
                <SpotsMarkers data={res}/>
            </Marker>
            )
        })
    );
}


  return (
    <View style={{flex: 1}}>
      <Map_BuilderDataContext.Provider value={{ setLegendId, newWaypoint, initialRegion }}>

        {/* Her eis map */}
        {events && spots ? <MapIsReady/> : <ConnectingToMaps/>}

        {/* <BottomScheet/> */}
        <MyBottomSheet isOpen={isOpen} onClose={() => setIsOpen(false)}>
            <MapLegendDetails legendData={legendData} />
        </MyBottomSheet>


      </Map_BuilderDataContext.Provider>
    </View>
  )
}

Steps to reproduce

.

Expected result

I was expecting to not reset to my position all the time

Actual result

Description

React Native Maps Version

1.7.1

What platforms are you seeing the problem on?

Android, iOS (Apple Maps)

React Native Version

0.72.6

What version of Expo are you using?

SDK 48

Device(s)

iphone 14 128gb iphone x and some redmi

Additional information

No response

@DETLIXX DETLIXX added the bug Something isn't working label Feb 26, 2024
@mateki0
Copy link
Collaborator

mateki0 commented Mar 3, 2024

HI @DETLIXX, thanks for reporting this. Can you try to reproduce it with minimum amount of code? If you have it inside context and passing and you are passing props to map component I can't reproduce it on my environment. From the first look I would say that there might be too many re-renders which are causing this bug. But I wouldn't say it's a library bug. The best way to debug this is creating new screen with map, bottom sheet and mocked data for region and markers and see if it works fine. If it does you can add more functionalities from your map component and at some point you will find out what's wrong.

@K4CZP3R
Copy link

K4CZP3R commented Mar 8, 2024

change followsUserLocation={true} to followsUserLocation={false}

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

No branches or pull requests

3 participants