Giter VIP home page Giter VIP logo

locationpickerview's Introduction

LocationPickerView

MKMapView + UITableView + Parallax scrolling. Provides a framework for building an interactive location picker on iOS.

This view is useful for when a list of scrollable, selectable locations need to be shown along with their locations on map. A search bar can easily be added for searching or filtering.

Install

Cocoapods

pod 'LocationPickerView', '~> 1.2.0'

Manual

Drop the LocationPickerView folder into your app.

Usage

In the view controlller you'd like to use the location picker in, add the following lines to viewDidLoad:

LocationPickerView *locationPickerView = [[LocationPickerView alloc] initWithFrame:self.view.bounds];
locationPickerView.tableViewDataSource = self;
locationPickerView.tableViewDelegate = self;
[self.view addSubview:self.locationPickerView];

Alternatively, you can setup the LocationPickerView in a Storyboard. Just set the view's class to LocationPickerView

and be sure to hook up the table view delegate and datasource.

Advanced Usage

If you want to get fancy you can specify more options:

// Create the location picker
LocationPickerView *locationPickerView = [[LocationPickerView alloc] initWithFrame:self.view.bounds];
locationPickerView.tableViewDataSource = self;
locationPickerView.tableViewDelegate = self;

// Optional parameters
locationPickerView.delegate = self;
locationPickerView.shouldCreateHideMapButton = YES;
locationPickerView.pullToExpandMapEnabled = YES;
locationPickerView.defaultMapHeight = 190.0;
locationPickerView.parallaxScrollFactor = 0.4; // little slower than normal.
locationPickerView.backgroundViewColor = [UIColor yellowColor]; //set color to the tableView background without the map

// Optional setup
self.locationPickerView.mapViewDidLoadBlock = ^(LocationPickerView *locationPicker) {
    locationPicker.mapView.mapType = MKMapTypeStandard;
};
self.locationPickerView.tableViewDidLoadBlock = ^(LocationPickerView *locationPicker) {
    locationPicker.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
};

[self.view addSubview:self.locationPickerView];

Of particular use is the delegate property which allows you to know when important things are happening (like the map view is about to expand full screen).

NOTE: Don't set the backgroundColor property of the table view. Color your cells or the LocationPickerView instead.

Feature Wishlist

  • Add map annotations that sync with table view.
  • Add some basic search functionality.
  • Add more map controls (zooming, following user location, etc).

Known Issues

  • Currently, deselecting a cell with animation doesn't look so good. You'll need to animate this yourself but hey, you can make it fancy!

Contributing

  1. Fork
  2. Code
  3. Comment :)

License

The MIT License Copyright (c) 2013 Christopher Constable

locationpickerview's People

Contributors

cconstable avatar hoya avatar charliefancelli avatar lngramos avatar mathisonian avatar tibolte avatar exister avatar

Watchers

James Cloos avatar David Qorashi avatar Dave Woollard avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.