GithubHelp home page GithubHelp logo

myell0w / mtlocation Goto Github PK

View Code? Open in Web Editor NEW
341.0 14.0 45.0 362 KB

A Framework to add convenience-stuff for easier coping with CoreLocation/MapKit on iOS. It includes a custom UIBarButtonItem mimicing the Locate-Me-Button of the built-in Google Maps App

License: MIT License

Ruby 1.55% Objective-C 98.45%

mtlocation's Introduction

Read Me

Currently Idle Currently searching for a location Currently receiving location updates Currently receiving heading updates

Description

These classes aim to mimic some of the functions of the built-in Google Maps App on iOS for you. Currently the library contains a simple Location Manager-Singleton that sends out notifications when CLLocationManager-Delegate-Methods are called and a UIBarButtonItem/UIButton that acts as a Locate-Me Button that behaves similar to the one in the Google Maps App. The switch from one mode to another is animated, just like in the Google Maps App.

It can also be customized to support Heading-Updates, by setting property headingEnabled.

Routes/Directions

If you want to display routes directly on top of MKMapView have a look at my new framework MTDirectionsKit: mtdirectionsk.it

Installation

Just copy over all .h and .m - Files to your project, as well as the image bundle included. You may exchange the images with your own, but make sure to adopt frames and sizes in the code, if your images have a different size than the one provided (only if there are any visual quirks).

Usage

Here's a minimal example of how to use MTLocation: https://gist.github.com/1373050

If you have problems getting the map-rotation to work, please refer to the following thread on StackOverflow: Rotating MapView

Update: MTLocation now provides the category-method [MKMapView sizeToFitTrackingModeFollowWithHeading] to automatically size the MapView.

You can use MTLocateMeBarButtonItem like this:

 // Configure Location Manager
 [MTLocationManager sharedInstance].locationManager.desiredAccuracy = kCLLocationAccuracyBest;
 [MTLocationManager sharedInstance].locationManager.distanceFilter = kCLDistanceFilterNone;
 [MTLocationManager sharedInstance].locationManager.headingFilter = 5; // 5 Degrees

 // Create MapView
 self.mapView = [[[MKMapView alloc] initWithFrame:CGRectZero] autorelease];
 [self.view addSubview:self.mapView];

 // create locate-me item, automatically prepare mapView
 self.locateMeItem = [UIBarButtonItem userTrackingBarButtonItemForMapView:self.mapView];
 // add target-action
 [self.locateMeItem addTarget:self action:@selector(myCustomSelector:) forControlEvents:UIControlEventTouchUpInside];
 // disable heading
 self.locateMeItem.headingEnabled = NO;
 
 // create array with ToolbarItems
 NSArray *toolbarItems = [NSArray arrayWithObject:self.locateMeItem];
 // set toolbar items
 [self.toolbar setItems:toolbarItems animated:NO];

mtlocation's People

Contributors

alexleutgoeb avatar alloy avatar foodtruckfiesta avatar johanns avatar lippling avatar messi avatar myell0w 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

mtlocation's Issues

resources

nice work!

I'd move the png files into their own .bundle to allow easier integration. It would also be fine to have a 40x30 frame (the frame could be even drawn with code instead of being an image).

thanks for your work!

p.s.
the background could probably be a black layer overlay with alpha 0.3, should be easy to implement with CALayer

UIButton Example

Hello,
is it possible to have a working example with a UIButton object?
Thanks

Workable example

It is a very useful library. I am new to iOS and spent hours to intend to make it work but was failed. Could you provide a compilable project or a UIViewController that contains all required code? A workable example would be extremely valuable!!

Help With Map Snapping to Location

I'm trying to work through your code in order to add a condition that the button only snap to the location if the location is within a region I've defined. As soon as I press the button, the map snaps to the location (as it should). I'd like to keep it from doing that if it's not inside the region. Can you help me figure out where to add this condition? I figured out how to stop the location updates but not the initial snap to location.

Thanks!

documentation

Hi, great work!

However, I find that the documentation is severely lacking explanations on how to use your library. It could be just a practical, small example (e.g., how to get notifications) or - preferably - thorough documentation.

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.