Skip to content

Latest commit

Β 

History

History
39 lines (31 loc) Β· 1.42 KB

open-maps-08-1-17.md

File metadata and controls

39 lines (31 loc) Β· 1.42 KB

Deep Linking Maps For A Location

By: Brandon Him - Brh55
Contributors: N/A

react: ^16.alpha.X
react-native: ^0.43.0

Most likely supported for older versions of RN > (~0.34)

Problem

Your component needs a deep link to open up Google Maps or Apple Maps for a location.

Solution

  1. Use the linking library provided by react-native

    import { Linking } from 'react-native';
  2. The .openURL method can take the following URLS to open the corresponding map application:

    Linking.openURL(`http://maps.apple.com/?ll=${LATITUDE},${LONGITUDE}`)
    • Google/Android:
      • geo:${LATITUDE},${LONGITUDE}
      • http://maps.google.com/maps?q=${LATITUDE},${LONGITUDE}
    • iOS:
      • http://maps.apple.com/?ll=${LATITUDE},${LONGITUDE}

✏️ Pro-Tip
Use Platform.OS (=== 'ios' || 'android') to allow cross-platform linking

πŸ—’ Note
You can also pass in the z query param to set desired zoom levels
IE: http://maps.apple.com/?ll=37.484847,-122.148386&z=15

Additional Information