Visual Explanation animateToRegion
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="YOUR_API_KEY"/>
Blog - Introduction to react-native-maps
react-native-geolocation-service
Uses the recommended
Google Location Services API
.
npm install react-native-geolocation-service
if (Platform.OS !== "android") {
Geolocation.requestAuthorization();
} else {
try {
const granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
{
title: "",
message: "",
buttonNeutral: "Ask Me Later",
buttonNegative: "Cancel",
buttonPositive: "OK",
}
);
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
} else {
}
} catch (error) {}
}
info.plist
NSLocationWhenInUseUsageDescription
NSLocationAlwaysUsageDescription
NSLocationAlwaysAndWhenInUseUsageDescription
AndroidManifest.xml
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Ref: Setup
Uses the
android.location
API which is not recommended by Google because it is less accurate and slower than the recommendedGoogle Location Services API
.
npm i -D @types/googlemaps
Reference: TypeScript and Google Maps
const address = address_components.reduce((seed, { long_name, types }) => {
types.forEach((t) => {
seed[t] = long_name;
});
return seed;
}, {});
How to parse google maps Address components. (geocoder response)
- Download a GPS spoofing app
- Enable Developer options
- Select mock location app
- Spoof your location