Draw a path between two coordinates in MapView (iOS) [duplicate] - iphone

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Show route between current and desired location on iPhone MapView
I am trying to draw a path between two coordinates on a MapView in iOS, but I can't figure out how. I have the two latitude and longitude points in one view.
How can I draw the path between these two points? I've attached the example with this question. Please help me. Any tutorials and code will be appreciated!

A simple answer is; you can't. At least, not using the built in API methods of iOS.
As far as i've seen so far, you have three alternatives:
Use an external library that offers such functionality - i'm sure there are plenty to be found on GitHub.
Compile the appropriate url and open mobile safari pointing to Google Maps with a directions request.
Use the built in methods of iOS 5/6 to open your route in the native Maps.app
I've used the third method in an app and this works fine but does come with the disadvantage that users will have to leave your application when viewing directions in Maps. It does however remain consistent and not quite as jarring to the user than opening mobile Safari.
If you do find a way to do this inside your own app, i'd be interested in seeing your results.

Related

Showing route in google maps in iphone

I have to display path between multiple locations in map in which travelling salesman problem should be solved. i used google direction api but it can handle only 8 way points in reguler account .i have to display path between cities more than 8 ...should i make algorithem for that ?can anyone help in this
Thanks .
Well for this you need to implement the Map Routes Methods. You can make it yourself but there are already classes made for this before. Please check :-
https://github.com/route-me/route-me
Google Maps SDK for iOS and routes
How to draw routes on maps in ios 6?
Hope this helps you otherwise please tell . I can provide you some classes

Xcode Google Maps Search Bar

I'm making an iPhone location based app and I'm having trouble with the last aspect of it. I was wondering if anyone knows how to integrate a search bar that correlates with the map that we can use from MKMapView.
It's literally a search bar above the map that the user can type in an area and it will take them there.
Is this possible?
I've looked around for tutorials but I have only found how to make an app with a map view, annotations and adding callouts.
What you're looking for is geocoding - the process of turning an address in your search bar into a latitude/longitude coordinate, which you can then set the map's position to.
This question has two main answers. This answer shows how to geocode using a Google API, and this answer shows how to geocode using an Apple API.
If you're using MapKit (which uses Apple maps as of iOS 6.0), then you should probably use the Apple API (you are not supposed to use Google Maps APIs with non-Google maps).
If you're using the new Google Maps SDK for iOS, you might want to use the Google API for geocoding. Although note that the answer I've linked to is using the Google API with MapKit (as it was written back when MapKit was using Google Maps), so you would need to modify it a bit.

iPhone: Using Google to get directions

In order to get directions, Google provides this nice URL:
Sample here...
How can I use the information that Google provides to get the same direction line on a MKMapView in an app?
You will have to either use a web view with a Google map, or draw on the MKMapView with overlays. There are a couple of projects on GitHub that do this:
https://github.com/kadirpekel/MapWithRoutes
https://github.com/kishikawakatsumi/MapKit-Route-Directions
In iOS 5, you can also open the maps app using an openURL call to the link you specified, and it will give you multiple possible routes to the location.
Unfortunately, the way to do it with the built-in MKMapKit is to calculate the route using some webservice then using MKOverlays to render that line. Those tools suggested by neven are probably a good first start.

how to create customer map on iPhone without using Google Map

I'm trying to integrated in our iOS app. Due to the bad relationship between Google & our government, Google Map is not a good idea.
We have bought a local map service company's javascript & Web Services based SDK, now we want to use it on iOS. But it seems that MapKit does not support customer tiles.
So here are my current ideas:
Use UIWebView. But I tried that map in Safari, I can't drag to move the map nor use two fingers to zoom. I think I need to call some javascripts while touch events happens.
Build a costumer UIScrollView, download map images and display them using iOS sdk. But that map service does not have API to download images, I tried to read their 200KB+ undocumented javascript to find out the relationship between location & image files, but I got no results for now.
Both the two ways could face certain legal risks. I'm not sure what the purchase contract is like.
I need suggestions about the two ways or some new ideas. Thanks guys.
There are a couple of non-Google map implementations available on github that you might be able to use (linked via CocoaControls):
NAMapKit
MRMapView

Route Map in iPhone

Does iPhone sdk supports route between two places on Map? I have searched many times. But not able to find any reference. Even on apple iphone development forums, there is no such thing available.
I have done this functionality using google map url. In which I have to pass source and destination latitude & longitude. I am getting the map but it is not as much good as like the iphone google map.
Can anyone help me out to do this functionality? I need to display map route between two places and also want description of the exact path to reach the destination.
No, the API has no means to do routing. You can do overlays if you can figure out the route, but that's obviously a lot more work.