About Drawing Maps In CarpPlay - ios

I want to draw directions to a specific location in CarPlay. I realized that there are two different options that can be made regarding this. First of all, drawing a direct route from current location to the desired location. The second is to draw the route after showing our current location and selecting the location which we want to go on the map.
Which would make more sense for me to do?
Which authorization is appropriate for the situations I have mentioned?
com.developer.apple.carplay-parking or com.developer.apple.carplay-maps?
Parking or Map?
If you are developing a CarPlay application I would appreciate it if you would also write about the resources you used on the subject.

Related

Determine is user is outside polygon area with Apple Maps

Is there any possibility to determine whether a user is inside or outside of a polygon area that I have marked on the map?
I would like to trigger an event if the user goes outside the area (only within the app, so no need for region monitoring)
I was having the same problem on Android a while back.
I don't think this functionality is provided by IOS either, so you will have to find a way of making a custom function involving this:
Point In Polygon Algorithm
I found the solution here: - This takes a MKPolygon (which is important in this manner, since we can then know that the area is closed. So this is not possible to do if you make multiple polylines, since there is no good way of saying that they are connected to each other.

Free drawing on Maps

I need to create functionality where a user draws (freely) his daily route on a map. Using iOS Maps / Google Maps SDK, how can I achieve it? The MapView will be fixed at a location and a zoom level, so it doesn't move while the user is drawing. The user has to draw a route along the roads shown on the screen. How can I achieve this ?
This is implemented in this app
"There is no way to do that with MapKit: it's easy enough to draw lines when you know the coordinates, but MapKit won't give you access to the roads or other routing information. I'd say you need to call an external API to get your data"
Reference article: Drawing a route in MapKit in iPhone SDK

How manage when several annotations has similar or the same coordinates and want to show them?

I have an app (iPhone) that uses MapKit and users can create things on the map (annotations in the remote database, with latitude and longitude).
Problem is that very often users put things in the same building, very close, even in the same coordinates. So you only see the most up-to-date annotation unless you tap it and another is shown, but the usability of this is horrible. No users realize they can do that.
Therefore I guess a way to group close points and when tap, show all of them. It seems the first step can be done with clusters and I see several libraries for iOS for that:
http://cocoapods.org/?q=on%3Aios%20cluster
I would like to know if you have any idea or suggestion to solve the second problem, or the whole problem.
Thanks in advance.
Depending upon the clustering library used, you may be able to get the clustered region that is represented. Then, upon cluster marker tap, you could zoom to that region.
The JS library Leaflet has this behavior so you can see what it's like:
http://leaflet.github.io/Leaflet.markercluster/example/marker-clustering-zoomtobounds.html
I realize this is a JS library not ObjC, but just linking it for demo purposes.

iOS MapKit - defining irregular touchable regions

I'm working on an app that lets a user select locations on a map. The entire map is subdivided into irregular regions (administrative boundaries), and when a user touches a point on a map, I need to be able to figure out which region the point belongs to. Just to clarify, there is no finite set of points for a user to choose from, they just tap anywhere on the map.
What is the best way to achieve this? I have been looking at MKPolygon class but cannot really figure out if this is the way to go. If it is, would I be using intersectsMapRect: method of the MKOverlay protocol to check for a match? Are there any good tutorials on this kind of map operations?
A good approach here might be the MapBox iOS SDK and it's RMInteractiveSource, which is designed for this. Check out this sample app which shows interactive regions.
This is done by a space-optimized, offline-capable key-value store of sorts that keys pixels at varying zoom levels to arbitrary content values (region name, data, imagery, etc.)
In MapKit proper, you'll need some sort of spatial analysis (maybe Spatialite?) to determine intersections between points touched and irregularly-shaped regions.

Snapping user location in MKMapView to a line/trail

I am working on a trails/maps app that has custom trails mapped out in a region and will aid the user navigate his or her way around some trails in a "foresty" area.
Currently, I am using MKMapView to get the user data/location, and loading the trails as overlays from a KML file. The problem I am having is that while testing the app, I noticed that in some situations the blue dot representing the user position goes off the trail overlays, which is expected since GPS (especially on phones) is not that great, plus some error that might have been obtained when getting the values for the trails to put in the KML file.
I apologize if all of that is a bit confusing, my question is: Is it possible to "snap" the user location (the blue dot that we all love) to a trail/overlay/path that is placed on the map with a specific tolerence? for example, if the blue dot appears to be a few pixels off the trails, then it would be placed right in the middle of the trails. If it is far off, then the user probably walked off the trails, and no snapping will happen to the user's location.
First off I wouldn't bother. If they are just a few pixels off they won't care, but if they are further away then it's important that they know where they are as accurately as possible. They could be lost in the snow and looking for trail markings.
If you do go ahead with that you'll have to abandon the userLocation dot and build our own. Using a LocationManager you can get told every time the device gets new location information and move your custom annotation dot to where you think they should be. More trouble that it's worth IMHO.

Resources