Open map within application for iOS6 or previous

I have lat and long of address and I want to open maps for both iPhone Map in iOS6 and Google Map before iOS6 within application. I tried to open map of google for before iOS6 but it not working. [[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:@"comgooglemaps://?center=46.414382,10.013988&mapmode=streetview"]];

I am doing above line of code mentioned but its not working. Kindly if any one know please help me on that. Thanks in advance.

Answers


There are two different methods: canOpenURL and openURL

With canOpenURL you only check it it is possible to open an external application (in your case the map app -from Apple of from Google-.

Once you have checked it, you have to use [[UIApplication sharedApplication] openURL:NSURL URLWithString] to open it.

So you can try:

if ([[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:@"comgooglemaps://?center=46.414382,10.013988&mapmode=streetview"]]){
    [[UIApplication sharedApplication] openURL: [NSURL URLWithString:@"comgooglemaps://?center=46.414382,10.013988&mapmode=streetview"]];
}

It is good to use canOpenURL, by this method you check if you are trying to open an app that is not present in the device so you can show an alert of some feedback to the user instead of a not working button without any "visual" action for the user.

Hope it helps.


Need Your Help

Java multi-clients server socket getting errors

java multithreading sockets networking

I've tried making a simple server to accept multiple sockets & then let them input and receive an output.

DotNetOpenAuth: Could not load file or assembly log4net, Version=1.2.10.0

assemblies log4net dotnetopenauth

It seems that the latest version of DotNetOpenAuth (4.0) uses fixed version of log4net - 1.2.10.0

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.