GithubHelp home page GithubHelp logo

khalidelsayed / sphlocationpicker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from skillpages/sphlocationpicker

0.0 1.0 0.0 467 KB

A location picker with a built in resizable maps and search options.

License: MIT License

sphlocationpicker's Introduction

SPHLocationPicker

SPHLocationPicker provides a configurable UITableView with a dynamically resizing MKMapView which can be used to allow a user select a location. The map can expand and contract as the user drags the tableview. The selected item can be returned to the calling controller as a CLPlacemark.

##Usage

    SPHLocationPickerViewController *locationPicker = [[SPHLocationPickerViewController alloc] initWithSucess:^(CLPlacemark *place){
        NSLog(@"place.addressDictionary: %@", place.addressDictionary);
    }
                                                                                                    onFailure:nil];

    UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:locationPicker];
    [self presentViewController:navController
                       animated:YES
                     completion:nil];

Installation

  1. Link CoreLocation.framework, MapKit.framework and QuartzCore.framework to your project. If you are using the default data source for the tableviews, you'll also need to link to AddressBookUI.framework
  2. Include the SPHLocationPickerViewController.h header
  3. Initialise the SPHLocationPicker
SPHLocationPickerViewController *locationPicker = [[SPHLocationPickerViewController alloc] initWithSucess:^(CLPlacemark *place){
        NSLog(@"%@", place.addressDictionary);
    }
                                                                                                    onFailure:nil];
  1. You can provide your own datasource for the UITableView using the property tableDataSource. This should conform to both SPHTableViewDataSource and UITableViewDataSource. A default implementation of this is already provided.
  2. Optionally set one of the configuration options.
  3. Push the controller

Options

bounce (default YES) When set to YES, the tableview map will return to the set size on release.

dropPin (default YES) Allow pins to be dropped on the map.

showUserLocation (default YES) Turn on or off the user's location.

searchable (default NO) When this is set, a datasource which conforms to both UITableViewDateSource and SPHAutoComplete must be provided. This will then display a search bar under the map which will allow the user to search for a location.

zoomToDroppedPin (default YES) When set to YES the map will zoom into the dropped pin.

mapHeight (default 150) The initial height of the map. If the map bounces, it will return to this size.

Example

To run the example project, you will need to initialise the SPGooglePlacesAutocomplete and SVProgressHUD submodules: $ git submodule update --init --recursive

Once initialised, you will need to provide your own Google Places API key.

SPGooglePlacesAutocomplete is used by ExampleAutoCompleteTableViewDataSource to provide the data for the autocomplete.

Requirements

SPHLocationPicker requires iOS 5.0 and above.

ARC

SPHLocationPicker uses ARC.

If you are using SPHLocationPicker in your non-arc project, you will need to set a -fobjc-arc compiler flag on all of the SPHLocationPicker source files.

To set a compiler flag in Xcode, go to your active target and select the "Build Phases" tab. Now select all SPHLocationPicker source files, press Enter, insert -fobjc-arc and then "Done" to enable ARC for SPHLocationPicker.

Creator

Karl Monaghan @karlmonaghan

License

SPHLocationPicker is available under the MIT license. See the LICENSE file for more info.

sphlocationpicker's People

Contributors

kmonaghan avatar

Watchers

 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.