How to bring the top bar in google maps in ios - iphone

I am developing an application in which i am opening goggle map in
webview with source and destination location but i am not able
to see the top bar which is displayed in the image attached.
http://i.stack.imgur.com/Yrwld.png
What i want is the top bar should also be displayed while opening map in iphone.
Kindly help.!In image it is showing the bar on the top.it is the default bar of google maps but i am not able get it .may i am not passing the correct url.the url i have given is :-
http://maps.google.com/?saddr=nagpur&daddr=pune&output=html

I am not clear about whether you are opening map in Safari or in same application using MapKit framework. But the top bar you are talking about will be displayed only if you open the map in Safari (as shown in code below), but if you are willing to have such control in your application map (ie using MapKit, MKMapView) you will have to code such control with same UI and functionality.
About the correct url for getting direction (in safari) see code:
NSString* url = [NSString stringWithFormat:#"http://maps.google.com/maps?saddr=%#&daddr=%#",
[source stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],
[destination stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
];
//where source and destination will be your address strings.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];

Related

how to open a website using SAFARI in fullscreen mode for iPad

I am having a requirement where a website ( url is hardcoded )would be getting open in full-screen mode
i.e. No address bar or No menu-bar buttons of SAFARI should be displayed in my application.
I am using following lines of code for the opening url in SAFARI browser.
NSURL *url=[[NSURL alloc]initWithString:#"http//www.google.com"];
[[UIApplication sharedApplication] openURL:url];
what properties shall I set for UIApplication so that I will get the SAFARI browser in full-screen mode in my app?
You can't do this from the Application, it is up to the website to try and enforce this. In order to achieve what you're after, I believe you need to make the website pretend to be a web-app.
Apple have documentation on how to customize Safari for your website, see http://developer.apple.com/library/safari/#documentation/appleapplications/reference/safariwebcontent/configuringwebapplications/configuringwebapplications.html, specifically "Hiding Safari User Interface Components"

How to make link open "Maps" window when clicked

I would like to have a link in a web page in such a way that when the link is clicked it opens the standard "Maps" view in iPhone.
If such a thing is possible, what tag format do I need to use with the link?
It's pretty simple; you don't even need to use a specific scheme identifier. Any Google Maps URL will be opened with the Maps app automatically, as long as all the parameters are supported.
So links like these:
http://maps.google.com/maps?q=cupertino
http://maps.google.com/maps?daddr=San+Francisco,+CA&saddr=cupertino
Would automatically be opened in Maps. To find out more about what works and what doesn't see the Map Links page from the Apple URL Scheme Reference.
I used this code which works passing longitude lattitude:
NSString *url = [NSString stringWithFormat: #"http://maps.google.com/maps?saddr=%f,%f&daddr=%#",cur_lat, cur_lon,[loc stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSLog(#"current %f %f",cur_lat,cur_lon);
[[UIApplication sharedApplication] openURL: [NSURL URLWithString:url]];

how to move moretab in iphone

in my applicaton,i have one directions tab in moretab.In directions tab, i displays the safari view through coding like this
NSString* url = #"http://maps.google.com/maps?saddr=33.68325,-117.834073&daddr=33.67425,-117.835073&dirflg=w";//[NSString stringWithFormat: #"http://maps.google.com/maps?q=%#",#"1101+E+Fletcher+Ave+Tampa+FL+33612"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
when click the directions tab it shows the safari browser.But my problem is after open the safari view, iam not able to move the more tab again. now what i want be done is ,when closing this safari view and reopen my application it directly shows the more tab not directions tab.How to do this.
Often times directing the user to Safari can be very confusing and some users don't understand how to come back. Consider using UIWebView instead for this since it stays inside your app and also provides you with the control that you are talking about now.
If you absolutely have to direct the user to safari I would take a look at this post that talk about how to catch the events of a user leaving your app and different states for that.

Google Calendar Mobile Version - embed

I want to embed a google calendar into an iphone app, my webview is fine, except I can't seem to get the URL I need to view the mobile version without having to logging in.
I know its possible as this is done in the twit app (See Screenshot below).
How can I do this?
Lets say the public google calendar is link text and I want to view the Mobile version of this page in a UIView.
The mobile view is available at link text, but you must first be logged into a google account.
Help Stackoverflow!
alt text http://posterous.com/getfile/files.posterous.com/norskben/RtIkoblEW9VsBE07dAQy9Sjjo4aRL2yjCRTCIx316y7ovsCXo9iKeGLL1AMx/photo.jpg
All under control now. Although I didn't find it possible to access the gp mobile view, it turned out infact to be just the agenda view of the normal view.
NSString *gcal = [NSString stringWithFormat:#"<html><meta name=\"viewport\" content=\"width=320\"/><iframe src=\"http://www.google.com/calendar/embed?showTitle=0&showNav=0&showTabs=0&showPrint=0&showCalendars=0&mode=AGENDA&height=600&wkst=2&hl=en_GB&src=northadelaidefitness#gmail.com&color=%23A32929&ctz=Australia%2FAdelaide\" style=\"border-width: 0pt;\" mce_style=\" border-width:0 \" frameborder=\"0\" height=\"400\" width=\"300\"></iframe>"];
[webview loadHTMLString:gcal baseURL:nil]; //load above html string (notice the viewport=320 for iphone resizing
webview.delegate = self; //add delegate for activity access
webview.scalesPageToFit =YES; //scale nicely

Mapping data from RSS feed with no latitude/longitude using MapKit

Having follow the tutorial at http://mithin.in/2009/06/22/using-iphone-sdk-mapkit-framework-a-tutorial/ to integrate the MapKit into my application. However, I want to be able to display an annotation for a dynamic "incident" on the map. Here's where I'm having problems.
Basically my apps an RSS reader, and it downloads everything and saves each item of the feed (as in Story 1, Story 2) as currentItem. The data I want to grab and use to map the annotation can be found under currentItem.title - but I can't seem to get it to work in this tutorial's code or find the right place to put it.
The RSS feed I'm using doesn't have any latitude/longitude information either - making it even harder.
Any help would be great - I've been working on this for a couple of days now with still no luck.
UPDATE: I'm even considering launching the Google Maps application instead showing the annotation. But this in itself is raising issues. Below is the code I'm using but its throwing errors everywhere.
NSString *title = currentItem.title;
int zoom = 13;
NSString *stringURL = [NSString stringWithFormat:#"http://maps.google.com/maps?q=%##%1.6f,%1.6f&z=%d", title, zoom];
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];
In the end I just mapped the title using reverse lookup, and added the country afterwards so results would only be in the country where the address is. Not ideal, but it seems to work OK.