Updated for XCode 8.0 and Swift 3.0
Features:
Location update with closure & delegate support
Geocoding and reverse geocoding using Apple service
Geocoding and reverse geocoding using Google service
Closure returns CLPlacemark object, making it easier to place pin on map
Try this too: https://github.com/varshylmobile/MapManager
CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries. You can install it with the following command:
$ gem install cocoapods
To integrate VMLocationManager into your Xcode project using CocoaPods, specify it in your Podfile
:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
target 'TargetName' do
pod 'VMLocationManager', '~> 1.0.0'
end
Then, run the following command:
$ pod install
Closure
Location update
var locationManager = LocationManager.sharedInstance
locationManager.showVerboseMessage = true
locationManager.autoUpdate = false
locationManager.startUpdatingLocationWithCompletionHandler { (latitude, longitude, status, verboseMessage, error) -> () in
println("lat:\(latitude) lon:\(longitude) status:\(status) error:\(error)")
println(verboseMessage)
}
Geocoding using Apple service
var locationManager = LocationManager.sharedInstance
locationManager.geocodeAddressString(address: "Apple Inc., Infinite Loop, Cupertino, CA 95014, United States") { (geocodeInfo,placemark,error) -> Void in
if(error != nil){
println(error)
}else{
println(geocodeInfo!)
}
}
Reverse Geocoding using Apple service
var locationManager = LocationManager.sharedInstance
locationManager.reverseGeocodeLocationWithLatLon(latitude: 37.331789, longitude: -122.029620) { (reverseGecodeInfo,placemark,error) -> Void in
if(error != nil){
println(error)
}else{
println(reverseGecodeInfo!)
}
}
Geocoding using Google service
var locationManager = LocationManager.sharedInstance
locationManager.geocodeUsingGoogleAddressString(address: "Apple Inc., Infinite Loop, Cupertino, CA 95014, United States") { (geocodeInfo,placemark,error) -> Void in
if(error != nil){
println(error)
}else{
println(geocodeInfo!)
}
}
Reverse Geocoding using Google service
var locationManager = LocationManager.sharedInstance
locationManager.reverseGeocodeLocationUsingGoogleWithLatLon(latitude: 37.331789, longitude: -122.029620) { (reverseGecodeInfo,placemark,error) -> Void in
if(error != nil){
println(error)
}else{
println(reverseGecodeInfo!)
}
}
Delegate
Location update
*class ViewController: UIViewController ,LocationManagerDelegate{....*
override func viewDidLoad() {
super.viewDidLoad()
var locationManager = LocationManager.sharedInstance
locationManager.delegate = self
locationManager.startUpdatingLocation()
locationManager.stopUpdatingLocation()
}
func locationManagerStatus(status:NSString){
println(status)
}
func locationManagerReceivedError(error:NSString){
println(error)
}
func locationFoundGetAsString(latitude: NSString, longitude: NSString) {
}
func locationFound(latitude:Double, longitude:Double){
}
-
App is Authorized to use location services.
-
You have not yet made a choice with regards to this application.
-
This application is not authorized to use location services. Due to active restrictions on location services, the user cannot change this status, and may not have personally denied authorization.
-
You have explicitly denied authorization for this application, or location services are disabled in Settings.
Add Privacy - Location Usage Description and NSLocationWhenInUseUsageDescription in your plist
- Compatiblity check for iOS7 & iOS8
- iPhone4 and startMonitoringSignificantLocationChanges issue
All contributors will receive virtual high fives from me and for the heck of it lets forget you are a south paw
Map manager is a MapKit wrapper in Swift to provide route direction drawing
NSXMLParser wrapper in Swift
RateMyApp is a Swift class to provide gentle reminders to app user to rate your app
Vertical and Horizontal flip animation for table view cell
Have any questions or suggestions feel free to write at [email protected] (Jimmy Jose) http://www.varshylmobile.com/
The MIT License (MIT)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
locationmanager's People
Forkers
carabina subfactory dalongli emmerson packetfahrer coderxl prathumca noulik23 gbaladi alexguoq rtoya williamren wpxlove rinatkhanov ruler89 gregfussell fabnoe caselas frxer jianwche retsohuang baoluo ikalin handsomeko caoool ywxstar wolflb pandazheng pechitook kooqilylb laznrbfe dvt282 rtsbtx priestd09 billypchan daansari panwoman om3g4 davidwoods2992 renming bycreator arthurkk shidiansoftware michaelversus michael-patzer imjerrybao getmetorajesh wh1pch81n cloudjanak blockchainb charlespsdowd chinarefers guosongning jennygallagher cozkurt balao7 woshizilong gustavohansen iamulya cloudhm wiosif macvillanda szmichaelyb guodu koushikcr dylanmaryk bilawal-liaqat efremidze fraserscottmorrison mohala562 desmond0321 sunhdmn cangck arickxuan chengkaizone kimhongil chayelheinsen shibbyy lishengbing jeffery812 practicegithub2016 sundarsan peatiscoding mspviraj aricksm zikex sapto7777 runt18 jeongwooha rchatham rakshitha-m-rodrigo laocat2004 ggthedev zhshare filmhomage ju-skinner reversescale briansisney evilino jashionlocationmanager's Issues
CocoaPod name is a duplicate
I just spent 10 minutes trying to figure out why your documentation didn't match the LocationManager source. Its because pod 'LocationManager', ~> '1'
will download a different pod.
You should use a unique name
At the very least you should update your ReadMe to show that you need this to install your pod
pod 'LocationManager', :git => 'https://github.com/varshylmobile/LocationManager.git'
The update frequency problem
How to set up as distanceFilter attributes as system?Don't want to have been updated.
CocoaPods Support
Would you mind supporting CocoaPods?
Swift 3: crash to "as! CLGeocodeCompletionHandler"
the fileprivate func geoCodeAddress(_ address:NSString){}
caused an error due to a
warning: could not load any Objective-C class information from the dyld shared cache. This will significantly reduce the quality of type information available.
To correct it , it's enough to correct this line:
geocoder.geocodeAddressString(address as String, completionHandler: ({(placemarks: [CLPlacemark]?, error: NSError?) -> Void in
to:
geocoder.geocodeAddressString(address as String, completionHandler: ({(placemarks: [CLPlacemark]?, error: Error?) -> Void in
You can find more details also here in SO
You also don't need to force casting to as! CLGeocodeCompletionHandler
, so it can be removed.
[!] Unable to find a specification for `VMLocationManager`
When I try to make pod install
It is not working in Swift 3 and Xcode 8
Are you planning to support it for Xcode 8 or is there a workaround, I can use it in Xcode 8.
Thx
Too many errors for PromiseKit by Swift5
Too many errors for PromiseKit by Swift5
build errors
syntax erros
Pod name
Hi,
Thanks a lot for your work. Juste to notify that you specify
pod 'VMLocationManager', '~> 1.0.0'
in the documentation instead of
pod 'LocationManager', '~> 1.0.0'
Have a nice day !
Tom
Why i cannot retrieve my currently location?
Hi:
Recently, i used LocationManager to retrieve the user's current location with below codes:
var locationManager = LocationManager.sharedInstance
locationManager.showVerboseMessage = true
locationManager.autoUpdate = false
locationManager.startUpdatingLocationWithCompletionHandler { (latitude, longitude, status, verboseMessage, error) -> () in
println("lat:\(latitude) lon:\(longitude) status:\(status) error:\(error)")
println(verboseMessage)
}
But i found the completion handler never be called with no reasons.
Could you help me to figure out how make it works?
Thank you in advance.
Please update vor xCode 6.3
Thanks for updating to the latest xCode release
swift 2.0 + iOS 9.0
Package Guidance for installing in an earlier version of xcode.
Can I use it in Xcode 7.1 version which runs on swift 2.1 version?
(or) is there any lower version of LocationManger to support lower version of Xcode?
Not updated for iOS 9
Needs to be updated for Swift 2.
Crashes if types in address components is empty
In some cases Google Places API returns empty types array, for example Dallas/Fort Worth International Airport. In that case type = types.firstObject as NSString crashes
{
"long_name" = 2375;
"short_name" = 2375;
types = (
"street_number"
);
},
{
"long_name" = "Dallas/Fort Worth International Airport";
"short_name" = "Dallas/Fort Worth International Airport";
types = (
);
},
{
"long_name" = "International Parkway";
"short_name" = "International Pkwy";
types = (
route
);
},
{
"long_name" = Dallas;
"short_name" = Dallas;
types = (
locality,
political
);
},
{
"long_name" = "Tarrant County";
"short_name" = "Tarrant County";
types = (
"administrative_area_level_2",
political
);
},
{
"long_name" = Texas;
"short_name" = TX;
types = (
"administrative_area_level_1",
political
);
},
{
"long_name" = "United States";
"short_name" = US;
types = (
country,
political
);
},
{
"long_name" = 75261;
"short_name" = 75261;
types = (
"postal_code"
);
}
)
It is not supported for iOS 7. Please check
problem with LocationManager in Swift 2.1
In Swift 2.1 I have 2 problem:
- 'stringByAddingPercentEscapesUsingEncoding' was deprecated in iOS 9.0: Use -stringByAddingPercentEncodingWithAllowedCharacters: instead, which always uses the recommended UTF-8 encoding, and which encodes for a specific URL component or subcomponent since each URL component or subcomponent has different rules for what characters are valid.
- 'sendAsynchronousRequest(_:queue:completionHandler:)' was deprecated in iOS 9.0: Use [NSURLSession dataTaskWithRequest:completionHandler:] (see NSURLSession.h
please correct it
Optional("Invalid Input")
2014-12-21 01:47:22.945 LocationManagerDemo[1043:662184] * Terminating app due to uncaught exception 'NSGenericException', reason: '* Collection <__NSArrayM: 0x1c824d30> was mutated while being enumerated.'
*** First throw call stack:
(0x2946249f 0x36c58c8b 0x29461f21 0x33f4ee59 0x33fd8715 0x33fd1455 0x5a19db 0x5a9e29 0x5a42c9 0x5ab567 0x5ab355 0x3731be93 0x3731be07 0x37319b90)
libc++abi.dylib: terminating with uncaught exception of type NSException
The problem starts here : self.mapView?.setRegion(theRegion, animated: true)
Cannot compile due to Swift 1.2 changes
I already made the changes, but I can't commit
Error over_query_limit
Hi,
last time there is an always error when use geocodeUsingGoogleAddressString: Over query limit.
I think you should fix it in geoCodeUsignGoogleAddress and reverseGocodeUsingGoogle functions. Just add key parameters in the url string:
https://maps.googleapis.com/maps/api/geocode/json?address=\(address)&key=API_KEY
Broken link
Broken link url
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/varshylmobile/locationmanager/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
Line
https://github.com/varshylmobile/LocationManager/edit/master/README.md#L261
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.