Directions not following road on IOS map - ios

I am working on an app where I give direcctions in a country. Directions in that country is not available from apple so i decided to use google api on an apple map. However as you can see from my sceenshot. Although I find the location on my iphone mmap i just get straight lines versus following the route that google does.
Does this have anything to do with using google API on Apple Maps? I have no reason why this is happening.
this is the link I pass to the web from my app
http://maps.googleapis.com/maps/api/directions/json?origin=15.299503,-61.387292&destination=Rosalie+Bay+Resort,+Rosalie,+Saint+David+Parish,+Dominica&sensor=true

If you are using MKMapView, you should check out the following examples:
http://www.meonbinary.com/2014/02/route-directions-with-ios7-mapkit-and-google-maps-api
http://sugartin.info/2011/10/12/drawing-route-on-google-map-mkmapview/
If you are using GMSMapView, check out this stack question: Drawing Route Between Two Places on GMSMapView in iOS

I know this is an old thread, but you are not getting 'weird' polylines..
You drawn them manually from the steps.
If you look closely on the right map, you see the 'white' dots ?
Your polylines follow these dots, you can name them the direction steps.
I have the same issue when I simulate the directions :) That's how I got here.
For just drawing, draw routeRequest.routes[0].polyline directly to the map, and it looks good :)

Related

Draw polylines which follow the roads gemoetry

In my app I want to highlight certain roads, which can easily be achieved just by drawing polylines on top of the roads. (I am using the Google Maps SDK, by the way). However these polylines won't follow the road's geometry, they will just connect two coordinates with a straight line. (I have a coordinate for the start of the road which I want to highlight and the end of it). The coordinates won't change, the same roads will be highlighted through out the whole time in the app.
The question is: Is there a way I could draw these polylines not to be straight but to follow the road's geometry? If it's not possible in the SDK, is there a tool on the internet which will connect two coordinates following the roads between them? Because if there is, than I could get the coordinates of those poylines and parse them in my app.
Cheers!
as #Fabian has suggested, if you have a small set of polylines to show in your app, and your app works mostly offline, it would be better to get all the polylines during the development. And there are two ways:
1) through the direction API, you might able to skip all the implementation by using the WEB API, which is meant for webserver.
https://maps.googleapis.com/maps/api/directions/json?origin=Toronto&destination=Montreal&avoid=highways&mode=bicycling&key=API_KEY
2) or, with the Snap to Road API, which might gives you a better control over your route compare to the direction API. This API is meant to fix the pool GPS data you get from the sensor and snap those on the road.

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

Can iOS MapBox use rectangle offline map in .mbtiles?

I'm trying to make an offline map using iOS MapBox SDK. It's easy to make square map (eg. 32x32 tiles) but for some reason it doesn't work when I try to make rectangle map (eg. 40x32 tiles). It loads but it shows only a small portion of the map or skips some tiles. It just doesn't look as it should.
My .mbtiles looks correct, I checked .mbtiles and specification and it doesn't mention that there might be any problem with non-square maps.
Although, .mbtiles that comes with MapBox offline example called control-room-0.2.0.mbtiles is also square so maybe it's not possible for some reason.
Does anyone have experience with something similar?
A non-square region should work just fine -- there is no limit on this. One way to test your .mbtiles is to upload it to your MapBox account and see if it works on a web map. It sounds like your MBTiles file might have issues.

MKMapView clustering if too many Map Pins nearby

I'm wondering if any of you knows a method (library, category, etc.) to cluster iOS MapAnnotations if there are many of them at the same location (e.g. 4 pieces in about 10m).
It doesn't matter to zoom in because they are still overlapping. I've already tried https://github.com/applidium/ADClusterMapView (and sombe other libs) but all of them are made for showing clusters in zoom-out-scenarios. None of them really respect the distance between annotations when zoomed in.
I'm working on an app with an offline-db so a server-side solution is not an option.
thank you for your help!
You don't need 3rd party framework's anymore. iOS 11 has native clustering support.
You need to implement mapView:clusterAnnotationForMemberAnnotations: method.
Get more details in the Apple example: https://developer.apple.com/sample-code/wwdc/2017/MapKit-Sample.zip
You should have a look into CCHMapClusterController project, looks exactly like something you are looking for.
One alternative is the MapBox iOS SDK, which is an open source (BSD) library replicating MapKit behavior. It does both annotation clustering and offline map layers.
http://mapbox.com/mobile

Road with traffic on MKMapView

I have a question about the MKMapView component. I saw that on the native "Map" iOS app, we can draw the roads between different points and we can display the traffic for those roads. Well, that's exactly what I want to do for my app :)
So, I have two questions :
1) Firstly, how can I draw roads on a map. I read a lot of things about MKOverlay, about some samples which do that with JavaScript in UIWebView but what's the best way to do this ?
2) How can I know the traffic on a particularly road ? In order to draw the road in green, orange or red.
Thanks a lot !
Regards,
Sébastien ;)
Unfortunately by now CLGeocoder class from iOS 5 is just supporting to process address to geolocation transformation and reverse. It means to find address around the geocode you have or to find geocode of the address you provide. There are no possibilities access road graph to create routes (to select and draw roads precisely) and moreover to control traffic on the exact place. The only things you can do with standard tools is to draw overlays on the MKMapView with your own data.
To achieve the results you want I would offer to use the third party resources, Google Maps API for example, and use UIWebView to present a customized map. Google Maps JavaScript API v3 TrafficLayer

Resources