View Full Version : Having UIWebView load Google Maps in Maps
Apr 25, 2011, 06:57 PM
In one of my views I have an instance of UIWebView that loads a page with a Google Maps Form (Here (http://fadeproofonline.com/mobile/map/hbg.html)). When submitting the form in Safari, the Maps application will open with directions. When opening inside of my UIWebView, it will display Google Maps Mobile directions.
I've tried to change the User Agent of the browser so that it would think Safari was submitting the form, that didn't work. Then I tried Method Swizzling to change the user agent, which also didn't work.
Any idea how to open Maps when submitting my form within UIWebView?
Apr 26, 2011, 02:24 AM
Do u want the view, or the actual lines of what to do? isn't there an API to call in XML/JSON which u could parse? No idea, just trying to put idea's in here. Since i'm kind off interested too
Apr 26, 2011, 02:33 AM
Basically, I want the google maps link within my UIWebView to open in the Maps application as it would in Safari.
User presses the button hbgView to bring up hbgViewController using this code:
hbgViewController *hbgView=[[hbgViewController alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:hbgView animated:YES];
Then, I load the UIWebView session with the form using this code:
[svcWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"...com/mobile/map/hbg.html"]]];
The form code of the hbg.html document is as follows:
var baseUrl = "http://maps.google.com/maps?saddr="
var suffix = "&daddr=endaddress&hl=en";
<form name="gmform" method="post" onsubmit="redirect()">
<input type="text" id="url">
<input type="submit" value="Go">