Giter Site home page Giter Site logo

cconstable / locationpickerview Goto Github PK

View Code? Open in Web Editor NEW
222.0 16.0 45.0 3.36 MB

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

License: MIT License

Objective-C 97.83% Ruby 2.17%

locationpickerview's Introduction

LocationPickerView

n.b. This repo is old and no longer maintained. I'm leaving it as-is in the hope that it may still be helpful or at the very least, a relic of the past.

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 charliefancelli avatar exister avatar hoya avatar lngramos avatar mathisonian avatar tibolte avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

locationpickerview's Issues

Adding new MKMapViewDelegate

Hello Christopher,

How can I add some MKMapViewDelegate methods on LockerPicker?
For instance:

  • (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id)annotation

Sorry my mistake, just added
self.locationPickerView.mapViewDelegate = self;

Now, it's working!

Adding PullToRefresh

Hi,

This component is very interesting but how we can add a pull to refresh control ?

Thanks,

Hide map button is hidden by navigation bar on iOS 7

When running on iOS7 and after expanding the map view, the cross button appears to be hidden by the navigation bar. Could you confirm this? I have to put an offset to the cross button specifically for iOS 7.

How to center on user location when hidden?

I'm using the following code to center on the user's location, but the center point is at the bottom of the visible portion of the hidden map and not in the center of the hidden map. How can I center the map when it's hidden (not expanded)?

MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(user.location.coordinate, 4000, 4000); [self.locationPickerView.mapView setRegion:region animated:YES];

MKAnnotatioView Method is missing !

This code piece is good but missing support for MKAnnotationView.
The delegate method of -(MKAnnotationView*)is never called.
Please fix it in the future update !

Allow map to expand smaller than fullscreen

It would be nice to be able to expand the map, but still have some of the tableview show at the bottom. This is similar to how Foursquare and Highlight work. They show a portion of the tableview when the map expands to show the user that the list is still there (good for usability). If the user selects the small portion of the tableview showing, the map hides.

Unable to allocate render buffer storage!

If expand MapView to screen frame size, I got "Unable to allocate render buffer storage! 0x15d89650" in console.

If Change:
[self expandMapView:sender animated:YES];
To:
[self expandMapView:sender animated:NO];
The warning disappeared, but animation is canceled.

How to solve this issue?
Thanks for your consideration.

iOS 6 problem

I have tested your code with iOS 6 and there is a problem with the table view. Visible tableview rows are not selectable. Can you confirm this is a bug?

Tableview backgroundColor

Hello,

I'm having a issue when I have only 1 result on tableview. Since I have only one cell, under it is possible to see the map.
I cannot set background color to the tableview because will cover the map.
Is there any way to workaround this?

Thanks!

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.