Location & Maps

Get the device's location with the right accuracy, show maps with markers and routes, and use geofencing responsibly.

Intermediate · about 6 hours · difficulty 3/5

Learn first: Runtime Permissions & Privacy

Location powers delivery, ride sharing, fitness, weather and local search apps, but it is also one of the most battery-hungry and privacy-sensitive features.

Getting location

  • One-off position for "near me" features vs continuous updates for tracking.
  • Choose accuracy deliberately: approximate is enough for weather; navigation needs precise.
  • Foreground location is much easier to get approved than background location, which requires strong justification in both stores.
  • Libraries: expo-location, geolocator (Flutter), the Fused Location Provider (Android), Core Location (iOS).

Maps

  • react-native-maps or Expo Maps, google_maps_flutter, Maps Compose, and MapKit for SwiftUI.
  • Markers, clustering for many points, polylines for routes, and camera movement.
  • Map SDKs usually need API keys restricted to your app's package name or bundle ID.

Geofencing and geocoding

Geofences trigger when a user enters or leaves an area, with OS limits on how many you can register. Geocoding converts addresses to coordinates and back.

Pitfalls

  • GPS takes time and can be wrong indoors; show a last-known position and accuracy radius.
  • Continuous high-accuracy updates drain batteries quickly; stop updates when not needed.

Good enough to move on: your app shows the user on a map with nearby points of interest, and stops tracking when the screen is left.

Key concepts

  • Foreground location
  • Accuracy and battery trade-offs
  • Background location: Hard to get approved
  • Map views and markers
  • Marker clustering
  • Geocoding
  • Geofencing

Mini project

Build a nearby-cafes app that centres the map on the user, shows clustered markers from a public dataset, and opens directions in the system maps app.

Check yourself

What accuracy setting and update strategy would you choose for a weather app versus a running tracker?

Free resources