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.
Related
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.
I'm writing a program on WatchKit SDK. My aim is to generate a route between user's current location and another point. And I would like to catch a moment when the user should turn the corner. At the moment I wonder, what is a proper framework to use because in fact I do not need to display the map but do need to be able to build the route and catch the turns. Could you advice the proper way to do it?
If I understand your question correctly, you will need to track the users GPS coordinate in your WatchKit extension running on their iPhone. You will need to use the course and coordinate properties on the CLLocation object to determine when you are getting close or at the correct corner and then respond accordingly.
Here is some more info on tracking GPS coordinates in a WatchKit extension How to calculate current location in WatchKit extension
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.
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.
I'm able to show current location on mapview. It shows round blue color circle. When I click on the circle, it shows "Current Location".
I want to show users current location as green pin. on click of pin, i want to show "My Location" annotation. How to do it.
Please suggest me how to do it.
Doing so is a bad idea. The blue dot and associated animation is a convention that is adhered to by all MapKit apps. Your user might be moving too. A pin is associated with a fixed location. Someone holding a phone is not a fixed point.
Please really think about the MapKit standards and Apple HIG they are there to help your users understand and enjoy your app.