Add address annotation when finding route via google maps api - ios

I'm using google maps to get directions from one place to another. Here is the code
NSString *mapAPIString = [NSString stringWithFormat:#"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f",
sourceAddress.coordiate.latitude,
sourceAddress.coordiate.longitude,
destAddress.coordiate.latitude,
destAddress.coordiate.longitude,
];
NSURL *url = [[NSURL alloc] initWithString:mapAPIString];
[[UIApplication sharedApplication] openURL:url];
The code works perfect. But both addresses are marked as 'Unknown address' in iOS Map App. Is it possible to add custom title for each address ?

iOS 6 is still under NDA, but if you have access to the docs have a look at them and you will probably find useful information for this problem.

Related

Add transport type when showing Directions on map

How can I add transport type when showing Directions on map
I have used this code so far, but it is showing Walking distance on map
NSURL *URL = [NSURL URLWithString:#"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f"];
[[UIApplication sharedApplication] openURL:URL];
You can add one extra param directionsmode for different direction mode like below :
NSURL *URL = [NSURL URLWithString:#"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f&directionsmode=transit"];
There are many types of direction mode :
driving
transit
bicycling
walking
Also you can use URLSchema for open app with schema like below Google Map Guide
Google Map URLSchema Guide : https://developers.google.com/maps/documentation/ios-sdk/urlscheme

How to find direction between two location in iPhone application?

I am trying to find direction between two location using iOS framework but I am not able to find proper solution .
You can use different methods for finding the direction between two location.
(1) Using Google Maps
NSString *urlString = [NSString stringWithFormat:#"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f", currentLatitude, currentLongitude, destinationLatitude, destinationLongitude];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
(2) Using Apple Maps:
NSString *urlString = [NSString stringWithFormat:#"http://maps.apple.com/maps?saddr=%f,%f&daddr=%f,%f", currentLatitude, currentLongitude, destinationLatitude, destinationLongitude];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
Please let me know if you need any help.
your question is not very clear, but i think you mean the bearing between two locations.
see this question:
Calculating bearing between two CLLocationCoordinate2Ds
If your points are close together just use trigonometry. That will be close enough. If they are farther away then you want a great circle course, use the Haversine formula.

Skobbler (GPS Navigation) does not open at specified location

I have the following code for opening Skobbler at specified location:
- (void)openSkobblerWithLatitude:(double)latitude longitude:(double)longitude {
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:
#"hybridnavigation://cmd=mapOverview&latitude=%f&longitude=%f",
latitude,
longitude]];
[[UIApplication sharedApplication] openURL:url];
}
It opens Skobbler, but the location is completely ignored. Is there something wrong with the URL or is this simply a bug in Skobbler?
Link for downloading Skobbler:
https://itunes.apple.com/us/app/gps-navigation-sat-nav/id370144231?mt=8
EDIT: This is what the final URL looks like:
"hybridnavigation://cmd=mapOverview&latitude=49.010066&longitude=8.396355"
I contacted skobbler's support and they confirmed that this is a bug on their side:
The command line integration does not work with the current version of the app. This problem will be fixed with the upcoming update. (At the moment, I cannot tell you an exact release date.)

iOS Apple Map native links - URL Scheme examples

In one of my projects I'm capturing the Lat/Long coords in a core data store, and later on providing this information in an email with Attached PDF.. On the receiving end, I'd like the convenience of another iPhone user to be able to click on the link, and go to that location in Apple Maps
I find the native apple map comes up, but it's simply an open map view w/no pin:
NSString *appleLink2 = [NSString stringWithFormat:#"http://maps.apple.com/maps
ll=%#,%#",self.lat,self.lon];
I'm creating the clickable in a common fashion with a CGRect, and NSURL
It appears on the surface that I should probably get the street address instead of the Lat/Long coords also, and use the address for better map resolution... Thoughts?
Also, I'm looking for examples of Apples URL Schemes to query strings mentioned in the Docs, but can't find any real examples... ll = , son =, t = , z =. I understand saddr and daddr, and am surprised that I can't find any reference or real examples anywhere.
If you want the pin to be placed on the map in Apple's Maps app, use a 'q' instead of 'll' in the URL:
NSString *appleLink2 = [NSString stringWithFormat: #"http://maps.apple.com/maps?q=%#,%#", self.lat, self.lon];
The following apple link has all details for the questions
http://developer.apple.com/library/ios/#featuredarticles/iPhoneURLScheme_Reference/Articles/MapLinks.html
USE NSString for URL
NSString *appleLink2 = [NSString stringWithFormat:#"http://maps.apple.com/maps
ll=%#,%#",self.lat,self.lon];
NSURL *myUrl = [NSURL URLWithString:[appleLink2 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
Then use myUrl is as URL.

how to open links in json in safari?

In my app I have a UITableView displaying tweets from a downloaded json file. Many of the tweets contain a link (to Instagram for example). How would I go about making these links open in Safari? What code would I need?
[[UIApplication sharedApplication] openURL:myurl];
Or is your problem elsewhere?
If that doesn't solve the problem, some code would be helpful to show what your table view cells look like.
First of all you will need to detect your links. Is the link part of the tweet string or is it a separate object in an array?
NSString *yourLink = #""; //we will need more detail in your question for this.
Once you have your link you need to store it as an NSURL like so:
NSURL *url = [[NSURL alloc] initWithString:yourLink];
And then you can open this in a browser using:
[[UIApplication sharedApplication] openURL:url];
It would be useful to see what you are displaying in your table. Is it an NSArray from your JSON, or an NSDictionary?

Resources