MapKit follow with heading without top down view - ios

I'm trying to develop an app with a built in navigation feature using Apple Maps. The goal is for it to show the user's current location and rotate to face the direction they are heading in. However, I'd also like it to not view from the top down, more of a tilt, like in Waze.
I can have it follow the user and rotate with the correct heading, etc. using .followWithHeading. But I can't figure out how to have it tilt. I've also tried using a map camera which enables me to tilt it. However, I then can't get the coordinates since I can't use both didUpdateLocation and didUpdateHeading in a single location manager. Any ideas?

Related

swift - update directions when user moves

I am writing an app where a user can select a location and then it will display the directions to it on the map. This functionality works fine, however I need the route to update on the map as the user moves. Currently I am using the didupdatelocations method and creating a new direction line from the new user location, however this results in the polyline being completely redrawn. I am trying to find a way to update the directions as the user moves similar to how apple maps/google maps does this. I do not want to use the navigation window if possible.
I am using the Apple mapKit.
i have looked for similar problems this one with google maps but there have been no replies.
I have seen another example (sorry cannot find link again) which makes an array of all the coordinates in the polyline although im not sure where i would use this or how to use this to slice or remove the unwanted part of the polyline.
At the moment my code does remove all overlays when a new direction is called, but if the overlays are not removed then I will end up with loads of lines on the map. I have tested removing the first polyline after the second polyline is created but that doesn't seem a very efficient way of dealing with this.
would appreciate any suggestions.

How do I display an arrow next to the blue dot in iOS MapKit

In the Apple Maps app there is a blue arrow pointing in the direction the phone is facing(marked on the attached screenshot).I can't find how to do the same in my app using MapKit.
I need the map to be facing north and the blue dot with an arrow, just like in the default mode in the apple Maps app.I know I can do this by manually drawing an arrow. But, since it is already implemented in the Maps app, is there a standard setting that allows to achieve this in MapKit?
Currently the only way to achieve this is to create it manually, as Apple does not have any exposed API for it yet.
I posted quite a detailed implementation answer on this post: https://stackoverflow.com/a/40808645/4769084
Basically you need to add your own 'blue arrow icon' to the mapView user location view, then track the device's 'heading' to rotate the 'blue arrow icon' appropriately.

Google Maps Center while zooming

I am using google maps in my ios app and I have fixed the marker in the centre of the view so as to get the centre location. Now, while zooming the marker is somewhere else and the current location is somewhere else.what I want to achieve is while zoomingIn or out my location should be in the centre of the map View how can I achieve it. Any help would be great.
Thanks in advance..
You can add this line allowScrollGesturesDuringRotateOrZoom to your GMSMapview. This setting controls whether rotate and zoom gestures can be performed off-center and scrolled around.
mapView.settings.allowScrollGesturesDuringRotateOrZoom = NO
For more information, check this page and this SO question.
If I understood your situation, you have a marker in the center of your map and then you want, in case the user make a Zoom to the map that the marker remain in the center. Well, that is achieved with this logic: You have to listen to the "Zoom changed" event of google map. In case this event is triggered, retrieve the coordinates of the center and recreate the marker with the new coordinates. Doing this in plain javascript is easy, but for what I am seeing now, in IOS could be a little bit more complicated. But, there are some links that I hope could help you:
To detect a Zoom Changed in GoogleMaps SDK IOS:
Is there a Google Map event listener for panning or zooming map?
To get the coordinates from the map center in GoogleMaps SDK IOS:
How to get coordinate center of gmsmapview in iphone

How to disable compass usage in Google Maps for iOS?

I found this in Google Maps API:
By default, no location data is shown on the map. You may enable the
blue "My Location" dot and compass direction by setting
myLocationEnabled on GMSMapView.
However, as it's stated, when I set myLocationEnabled to YES, both user location and compass direction are visible. Is there a way to keep user location but prevent compass arrow from appearing on the map? I don't use it in my project and I would like to save some battery by not using things I don't really need in my app.
Any ideas?

MKMapView rotation

Apple's latest Maps application allows a user to rotate a map. How can I add this functionality to my MKMapView? I presumed it'd just be a case of setting a boolean property (similar to zoomEnabled), but I can't find anything relevant in the documentation.
There is no built-in rotation support in the MapKit of iOS. You could use regular view transforms (but than all street names etc. will also be rotated of course), or you use the Google Maps SDK or MapBox or something else.
The Google Maps SDK does support rotation, even 3D rotation. The SDK Download includes an example project showcasing the functionality.
Actually MKMapView does support map rotation starting with iOS 5.0. Either you use the MKUserTrackingBarButtonItem control in your toolbar (user taps it until the map is rotating), or you set the userTrackingMode property to MKUserTrackingModeFollowWithHeading.

Resources