WatchOS InterfaceMap update user location on map - swift

Anyone know how to show the "blue pulsating dot" for the user devices location on watchOS InterfaceMap element?
In iOS this can be done to MKMapView by calling mapView.showsUserLocation = true. InterfaceMap for watchOS doesn't seem to be supporting this and I was wondering if there is some other way to do this. Of course this could be done manually by placing an annotation on the user location every time the location is updated, but it seems a bit clunky and it would be great to have the default blue marker for the user location.
Thank you

You cannot do this on watchOS. WKInterfaceMap can only be used to show a static piece of the map at the moment. WKInterfaceMap shows a noninteractive map for a specific location. You can change the location shown on the map dynamically, but there are no built-in methods to update it automatically to show the user location in contrast to what MKMapView can achieve.

Related

MKMapView setting userLocation

My map view should work in 2 modes: with enabled Location Services and with disabled. If user disables locations services, application must give him the opportunity to manually set his current location. Also application should display blue pin that looks like MKUserLocation default pin. But the problem is userLocation property is readonly. And according to apple's documentation about MKUserLocation
You do not create instances of this class directly.
Can someone help me to solve this?
You should provide your own blue pin. System blue pin is considered to be used as read only and if you'll try to use it in some other way that will certainly lead to problems. So if you need some custom current location pin behavior you should implement your own pin for sure. Use CLLocationManager to update location if location services are enabled.

iPhone : How do I display the user location on a map view without updating location / having GPS running in the background?

how do I display the user location in a mapView while not running GPS to update the location (at all)? Will
mapView.userTrackingMode = kCLLocationAccuracyNearestTenMeters;
do the job or will GPS still burn battery in the background?
Thanks :)
I'm going to attempt to answer your question as best as i can given the limited information.
The GPS has 3 main modes that go from low power to high power, low accuracy to high accuracy.
Location Tracking off
Background location updates (uses cell towers and wifi)
GPS location updates
An MKMapView will show a blue dot for the user location if you set showsUserLocation to YES. The MKMapView will use all available location methods to find the users location as accurately as possible and keep updating it while this is set to YES.
The tracking in MKMapView, a mode which keeps the users location centred on screen, moves the visible map region as the user moves and is available in iOS5. you are given three MKUserTrackingModes to choose from. From the docs:
MKUserTrackingModeNone: The map does not follow the user location.
MKUserTrackingModeFollow: The map follows the user location.
MKUserTrackingModeFollowWithHeading: The map follows the user location
and rotates when the heading changes.
So setting it to kCLLocationAccuracyNearestTenMeters isn't going to work as it is not an available option in this context.
Will showing the location burn battery in the background? It depends on what you mean by background. When the user taps the home button the MKMapView is forced to stop using the GPS by the system. While the app is running and the MKMapView is alive and has the showsUserLocation property set to YES it will keep using any available method, including the GPS, to update the location. You have a couple of strategies to reduce this.
1) presume that the user needs to see their location updated while the map is on screen. In which case keep showsUserLocation set to YES until the map is moved off screen, or the device is locked, then set it to NO
2) Presume the user only needs to see a static marker of their location from a particular point in time, like when the app is opened. In this case you need to make a CLLocationManager object, ask it to startUpdatingLocation, filter the delegate messages for the accuracy you want, and then turn off location updates (stopUpdatingLocation). You can then add an MKAnnotation to the MKMapView to show the user their location.
As you can see number 2 is more work, yet very power efficient. Number 1 is easy, but will use more battery while the map is visible. It is up to you to decide which behaviour the user expects and to implement your app accordingly.

MKMapViewDelegate notifing when user moved the map

I use an MKMapView in my application, and implement its delegate. As with the Google Maps, I want to know when the user moved the map.
If you open the Google Maps application, and press the GPS icon the button is set to the DONE style and the map centers to your location. Whenever you move the map the icon automatically gets back to PLAIN style.
How can I do the same thing?
Best regards,
Paul Peelen
I am not sure whether this will solve your problem. But try overriding regionDidChangeAnimated: method of MKMapViewDelegate.
Doc says: This method is called whenever the currently displayed map region changes. During scrolling, this method may be called many times to report updates to the map position. Therefore, your implementation of this method should be as lightweight as possible to avoid affecting scrolling performance.

Creating mapkit's showsUserLocation pin ripple animation

Has any one successfully created user location pin that has a ripple like effect that 4.x (or higher) mapkit gives when we use mkMakkit.showUserLoaction = YES;
If any one has done it please guide me how to do it or past sample code that does that effect.
The user location in the mapkit is read-only property. Has anyone able to move the pin from user actual location. That is in my senario when the user location is not available for cases like iTouch user can select his location, I don't want to show user at Infinite Loop,CA but the location he prefers to choose.

showsUserLocation with Location Services disabled

I have an MKMapView in my app and have a button that turns on showsUserLocation for the map, while the map is finding the location I display a spinner so the user knows its working. I know when to stop the spinner by adding NSKeyValueObserver to the map's userLocation property. However if the user has Location Services disabled then the spinner just keeps on going forever but nothing happens, is there any way to know when location services are disabled while using an MKMapView?
Use locationServicesEnabled, a boolean property of a CLLocationManager.
The MapKit support for automatically showing the user's location is pretty poor. The app I'm writing shows the user's location, but I use CLLocationManager directly and add my own annotation to the map.
Note that locationServicesEnabled is new in 4.0, so won't work if your deployment target is lower.
Edit: Nevermind -- the class method [CLLocationManager locationServicesEnabled] is new in 4.0. But there is a now deprecated instance property .locationServicesEnabled for earlier SDK's.