Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-location-picker-controller

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-location-picker-controller

React Native Wrapper for LocationPicker, a ready for use and fully customizable location picker.

  • 1.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
Maintainers
1
Weekly downloads
 
Created
Source

react-native-location-picker

React Native Wrapper for LocationPicker, a ready for use and fully customizable location picker.

Dependencies

  • react-native-navigation - native navigation library for React Native (required to natively display the location picker within RN)

Installation

  • Make sure your project relies on React Native >= 0.25

  • Make sure your project uses react-native-navigation and that you've followed the Installation instructions there

  1. In your RN project root run:
    npm install react-native-location-picker-controller --save

  2. In Xcode, in Project Navigator (left pane), right-click on the Libraries > Add files to [project name]
    Add ./node_modules/react-native-location-picker-controller/ios/LocationPicker.xcodeproj (screenshots)

  3. In Xcode, in Project Navigator (left pane), click on your project (top) and select the Build Phases tab (right pane)
    In the Link Binary With Libraries section add LocationPicker.framework (screenshots)

  4. Open your Xcode project and drag RNLocationPicker.swift, RNLocationPickerManager.h, RNLocationPickerManager.m from the folder node_modules/react-native-location-picker/ios into your project, in the dialog box let Xcode create Objective-C bridging header.(screenshot 1, screenshot 2)

  5. Editing <your project name>-Bridging-Header.h to import RCCExternalViewControllerProtocol.h and RCCViewController.h for Swift to use:

    //
    //  Use this file to import your target's public headers that you would like to expose to Swift.
    //
    #import "RCCExternalViewControllerProtocol.h"
    #import "RCCViewController.h"
    #import "RCTConvert.h"
    
  6. In RNLocationPickerManager.m, replace #import "example-Swift.h" to #import "<your project name>-Swift.h"

Support Props(Subset of LocationPicker)

Boolean
Property nameDefaultTargetRemark
allowArbitraryLocationfalseAllows the selection of locations that did not match or exactly match search results
mapViewZoomEnabledtruemapView.zoomEnabledWhether the map view can zoom in and out
mapViewShowsUserLocationtruemapView.showsUserLocationWhether the map view shows user's location
mapViewScrollEnabledtruemapView.scrollEnabledWhether user can scroll the map view
String
Property nameDefaultTargetRemark
currentLocationText"Current Location"currentLocationCell.locationNameLabel.textThe text that indicates the user's current location
searchBarPlaceholder"Search for location"searchBar.placeholderThe text that ask user to search for locations
locationDeniedAlertTitle"Location access denied"alertController.titleThe text of the alert controller's title
locationDeniedAlertMessage"Grant location access to use current location"alertController.messageThe text of the alert controller's message
locationDeniedGrantText"Grant"alertAction.titleThe text of the alert controller's Grant button
locationDeniedCancelText"Cancel"alertAction.titleThe text of the alert controller's Cancel button
Color
  • Using processColor to convert color, check example usage code at the end of README

  • Valid color formats for processColor are

    • '#f0f' (#rgb)
    • '#f0fc' (#rgba)
    • '#ff00ff' (#rrggbb)
    • '#ff00ff00' (#rrggbbaa)
    • 'rgb(255, 255, 255)'
    • 'rgba(255, 255, 255, 1.0)'
    • 'hsl(360, 100%, 100%)'
    • 'hsla(360, 100%, 100%, 1.0)'
    • 'transparent'
    • 'red'
    • 0xff00ff00 (0xrrggbbaa)
Property nameDefaultTargetRemark
tableViewBackgroundColorUIColor.whiteColor()tableView.backgroundColorThe background color of the table view
currentLocationIconColorUIColor(hue: 0.447, saturation: 0.731, brightness: 0.569, alpha: 1)UIImage()The color of the icon showed in current location cell, the icon image can be changed via property currentLocationIconImage
searchResultLocationIconColorUIColor(hue: 0.447, saturation: 0.731, brightness: 0.569, alpha: 1)UIImage()The color of the icon showed in search result location cells, the icon image can be changed via property searchResultLocationIconImage
alternativeLocationIconColorUIColor(hue: 0.447, saturation: 0.731, brightness: 0.569, alpha: 1)UIImage()The color of the icon showed in alternative location cells, the icon image can be changed via property 'alternativeLocationIconImage'
pinColorUIColor(hue: 0.447, saturation: 0.731, brightness: 0.569, alpha: 1)UIImage()The color of the pin showed in the center of map view, the pin image can be changed via property pinImage
primaryTextColorUIColor(colorLiteralRed: 0.34902, green: 0.384314, blue: 0.427451, alpha: 1)MultipleThe text color of search bar and location name label in location cells
secondaryTextColorUIColor(colorLiteralRed: 0.541176, green: 0.568627, blue: 0.584314, alpha: 1)MultipleThe text color of location address label in location cells
Number
Property nameDefaultTargetRemark
defaultLongitudinalDistanceDouble1000Longitudinal distance of the map view shows when user select a location and before zoom in or zoom out
searchDistanceDouble10000Distance in meters that is used to search locations

Usage

For a fully working example look here

First, create a placeholder screen for the location picker. The main purpose of this screen is to handle navigation events. See an example here.

Note: Make sure your screen component has been registered with Navigation.registerComponent like all react-native-navigation screens need to be, example.

Now, to display your screen, from within one of your other app screens, push the location picker:

import processColor from 'processColor';

this.props.navigator.push({
  screen: 'example.LocationPickerScreen',
  title: 'Pick  a Location',
  passProps: {
    externalNativeScreenClass: 'RNLocationPicker',
    externalNativeScreenProps: {
      currentLocationText: '当前位置',
      currentLocationIconColor: processColor('#72c02c'),
      allowArbitraryLocation: true,
      defaultLongitudinalDistance: 100,
    }
  }
});

Credits

License

Code in this git repo is licensed MIT.

Keywords

FAQs

Package last updated on 09 Aug 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc