animateToRegion not working Android

Hello all,

Recently ejected from Expo and the animateToRegion is not working for Android devices but is working on iOS devices.

Necessary data is making it to the method but the map is not animating. I’ve tried it with both a “duration” and without, and both times the results are the same (Map doesn’t animate to the new location).

Any help would be highly appreciated.

Here is my code:

    useEffect(() => {
        if (!selectedPlaceId || !flatlist) {
            return
        }
        const index = filteredItems().findIndex(item => item.id === selectedPlaceId)
        flatlist.current.scrollToIndex({ index })
        const selectedPlace = filteredItems()[index]
        
        const region = {
            latitude: selectedPlace.coordinates.latitude -.02,
            longitude: selectedPlace.coordinates.longitude,
            latitudeDelta: 0.08,
            longitudeDelta: 0.08
        }
        map.current.animateToRegion(region)
    }, [selectedPlaceId]);


    const filteredItems = () => {
        if (selectedItem) {
            if(props.userLanguage == 'fr' || props.userLanguage == 'fr-CA'){
            return items.filter((location) => location.subCategoryFR.some((subCategory) => subCategory === selectedItem))
            }
            return items.filter((location) => location.subCategory.some((subCategory) => subCategory === selectedItem))
        }
        return items
    }

Hey @madahatter, what are the relevant version numbers at play here? Also, are you testing on a device, emulator?

Cheers,
Adam

Hi Adam,

I apologize for the late reply. I got very frustrated with this problem and told myself I’d come back to it eventually.

Here I am googling the problem and I stumble upon my own question (my oh my this code looks familiar haha).

Any how, the versions are as follows. Any help will be amazing. I’m still at a loss.

“react-native”: “~0.63.4”
“react-native-maps”: “0.27.1”,

In case anyone is experiencing the same problem, after about 30 hours of banging my head against the wall I figured it out.

The problem is that Android is not able to take the coordinates as a String when animateToRegion(). You must pass them as an Int. iOS seems to parse the strings but Android does not. Seems like more and more people are running into this problem so hopefully this will help.