Google map sdk for IOS 8 does not update location - ios

I'm running on IOS8 simulator and counter this problem:
GMSMapView is able to load map but it didn't ask for Location's permission, thus it could not update current user's location. (I did set a custom location, using GPX file)
However, GMSMapView still works fine on IOS 7.1, 7.0 ...
My code is simple, init mapView, add it to controller's view and using KVO myLocation to observer location's change.
What should I do now ?

Google Maps SDK v1.8.1 doesn't request the location authorization that is needed in iOS8, so you need to do this in your application.
Use the CLLocationManager's requestWhenInUseAuthorization method, and in the authorization changed delegate, enable location updates in the map view when authorization can be given.
Also, don't forget to add the correct keys in the info.plist to explain to your users why you need their location, as without this the call to requestWhenInUseAuthorization don't do anything.

Related

Gps (Location) On and off functionality

I am using Swift 3.1 in my application. I am new to Swift programming.
I have to turn GPS on and off (Location) by button clicking from my app.
If I select GPS on, then the screen should navigate to another view controller.
The system automatically handles this and you as a developer don't have direct access to turning the GPS on/off. When you call any methods of CLLocation requiring the user's location (such as CLLocationManager().requestLocation() or CLLocationManager().startUpdatingLocation()), the system will handle the GPS on its own.

How to hide Location icon in an iOS app on screens that do not require it?

I am developing an iOS app with Xamarin.iOS.
I have granted permissions to use Location Services, and the Location icon is visible in the Status Bar as long as the app is running.
However, my app needs to get the current location on one screen only - the rest of the time location is not needed.
Is it possible to turn off (hide) the Locations icon when app is not really using it?
Answers I found are for old iOS versions or work on jailbroken phones. It is my understanding that Apple is preventing this now. I would appreciate a confirmation if this is at all possible or not. Or if it is possible - some Xamarin / Objective-C /Swift examples would be great.
U mean the airplane ICON in status bar?
This ICON will show when APP using location service, try to stop or remove your location request or mapView, your map SDK have their own interface, like:
locationManager = [[CLLocationManager alloc]init];
[locationManager stopUpdatingLocation];
and be sure other APP not using location service.
but it NOT sure the service will stop immediately, location manager just a monitor to system.
You can use requestAlwaysAuthorization instead of requestWhenInUseAuthorization on CLLocationManager.
NOTE : Provide the related NSLocationAlwaysUsageDescription in the
info.plist file, and then Blue Banner will not display.

How to set MKMapView activityType?

CLLocationManager has a property called activityType where we can set the type of activity that is associated with the location updates.
In my app, I display an MKMapView with user location on it so I do not use CLLocationManager. Since we can't access MKMapView's location manager, how do we set the MKMapView's activityType?
Thanks.
You can't and that's probably intentional. MKMapView uses CoreLocation to determine your location when you set showsUserLocation = NO, which I think is what you're doing. Per the description for that property:
... Setting this property to YES causes the map view to use the Core Location framework to find the current location and try to display it on the map. As long as this property is YES, the map view continues to track the user’s location and update it periodically. ...
If you want an activityType or desireAccuracy level of granularity you have to use the CoreLocation API classes. Namely CLLocationManager.
As an aside, I would assume that Apple's MKMapView is using the significant change location API to manage your location on the map (and possibly AGPS) to conserve battery life, but I could be wrong.
Anyway, I would just create an instance of CLLocationManager and set its activityType.

Google maps ios api using user's location in fitbounds

I am trying to set a bounds between the users location and a selected marker. I can set everything up properly but when I try to use the users location (mapView_.myLocation.coordinate) it says the lat and long are both 0. I did create a button to center the camera on the users location and it gets the lat and long just fine. Does not make any sense to me. Also I don't have a device set up to test so I am using xcodes iOS simulator with a location put into the simulator (is that where my problem is?). Any ideas?
Are you trying to access myLocation.coordinate from loadView or similar, ie when the app first starts up?
Generally when enabling location services the app doesn't receive a location update immediately, it comes through after some delay. So it's possible that myLocation.coordinate won't be valid in loadView, but will have a value set some time later (which is why it works with your button).
You could perhaps listen for changes to myLocation, and then set your bounds when it changes to something.

MapKit Changing the User Location Programmatically

I am trying to make a jogging app which will track where the user ran. It will draw a line on the map where the user is running. My problem is that how to test such an app. Is there anyway I can dynamically change the user location which will fire the didUpdateUserLocation delegate method?
The iOS Simulator supports that feature in the current beta version. You can even simulate a dynamically updating location.

Resources