iOS web app "Open this page in Maps?" popup when trying to open the Maps App - iphone

I'm writing an iPhone web app using HTML5/CSS3. I need to embed a link to open a built-in maps app from my web app. To open a location on the map I redirect mobile Safari to URL like this:
http://maps.google.com?q=Business+Name%26+Street+Address+City+State+Zip
In this case if a user taps on this link the iPhone opens up the maps app and displays the location specified in the URL.
But when I need to provide a URL for driving directions to a predefined location:
http://maps.google.com/maps?saddr=1234+1st+ave+portland+or&daddr=Business+Name%26+Street+Address+City+State+Zip
I've encountered a strange situation when in some cases the iPhone displays a pupup message:
Open this page in "Maps"?
with a choice of yes and no, and only if a user taps Yes, the maps opens up with directions. Note that this popup shows only for some addresses.
Is there any way to prevent this popup from showing at all?

I've created simple web page. Put a link and set google map link with query string value of particular address on src attribute of link element,run it to my iPhone 4.It is working fine, I'm not getting any window to ask it open on map app.
I noticed that you've used "saddr" as a query string parameter. You can replace that with "q" query string parameter.

Related

Passing values from webpage to Android activity

I have learnt how to open an android app from a webpage by making the HTML elements href like:
" Take a QR code "
But I have used webpages that not only opens up the app, but also passes some value to a specific field in the apps activity.
Eg: a web page that has a button, such that when clicked, opens up the compose mail activity in the Gmail app and fills the "to" input field with a specific email address.
Can this be implemented? How can I go about this .Thanks in advance.
Pardon me if I haven't asked this question properly.

Link to iPhone map App from HTML page

Is there a way to link to directions in the iPhone map app from a html page?
We're placing an add in an iPhone app which will link to a mobile page on our website - we'd like to add a directions link, thus far google searches have been unrevealing.
A link to http://maps.google.com/maps will automatically open in the map application
You can set a destination address (daddr) and start address (saddr) in the link:
http://maps.google.com/maps?daddr=San+Francisco,+CA&saddr=cupertino
You can see some more options at:
https://developer.apple.com/library/archive/featuredarticles/iPhoneURLScheme_Reference/MapLinks/MapLinks.html
Here is a javascript function that creates the link:
function mapLink(myAddress) {
return 'http://maps.google.com/maps?q='+escape(myAddress);
}
This works great on the iPhone.
If you use the standard link that would display a map in the browser, it will automatically open in Google Maps on the device. That includes links that show directions.
Use something like:
<a href='maps:daddr=<destination>&saddr=Current%20Location'>Directions</a>
where may be a lat/lon pair (separated by a comma) or a place. Ensure you URI encode the destination to ensure it works.

Access TomTom navigation solution via URL scheme

I'm currently working on an iPhone Application which allows the user to navigate to POIs. Those POIs are defined via lat/lon, and the user should have the possibility to start his navigation solution with one click to navigate to this POI.
This works fine with Navigon, using URL scheme navigon://myapp|name||||||lat|lon
Now I know that there is an URL scheme named tomtomplus:// for the TomTom iPhone app, I'm only able to start tomtom, no other action is possile.
I tried tomtomhome://geo:action=navigateto&lat=mylat&long=mylon&name=myname - but did not work. Only tomtom app is starting.
Even when I try to go over the http://addto.tomtom.com API, tomtom does only start, no action in adding and POI or chance to navigate to.
Codesniplet:
NSString* launchurl = [NSString stringWithFormat:#"tomtomhome://geo:action=navigateto&lat=%.8f&long=%.8f&name=%#", myEntry.getLon, myEntry.getLat, myEntry.name];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[launchurl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
Any suggestions?
I used Tomtom to send me an email from the route planning option on my iPhone. In that email is a tomtomhome:geo link which I used.
To test I clicked on the link on my Mac in Safari, and obviously nothing happened. Then I saved the link as a bookmark, which immediately is synced to my iPhone using MobileMe. I clicked on the bookmark on my iPhone Safari browser and viola Tomtom opens with a map centred to the location in the link. It pops up with a balloon with the links name, and an right arrow allows me to choose first option "Navigate there"
The link generated is:
tomtomhome:geo:action=show&lat=26.123456&long=28.123456&name=linkname

Link directly to Google Maps transit directions mobile site

If you visit maps.google.com on a mobile device, then press 'Menu', 'Get Directions', and select the 'transit' option, you are taken to a page where you can enter two locations and a date/time, and get directions on public transit. However, the URL is still maps.google.com.
Is there any way to link directly to this page so that I can load it in a UIWebView in my iOS app? Would 'clicking' the buttons in Javascript be (the only/a good) solution?
Try: http://www.google.com/transit
Even clicking the buttons in javascript doesn't seem to be working. The Google Maps code is a little strange- the event listeners aren't assigned directly and I can't get a .click() to work. So what I'll do is have the user enter the two locations in boxes in the app, then load something like http://maps.google.com/maps?f=d&source=s_d&saddr=Coover+Hall&daddr=lied+rec+center in the UIWebView, except I'll add some more specific location information before building the URL, since this is a city-specific app. Not a perfect solution but it gets the job done.
You could create a URL that links to the transit directions with the "dirflg=r" paramater.
Find the other URL parameters here: http://web.archive.org/web/20110714031648/http://mapki.com/wiki/Google_Map_Parameters

Possible to open iPhone Safari and target a specific window?

I have an app that uses OAuth to authenticate, which means the user must be directed to the website to authorize the application. I prefer to make it obvious to the user that they are using a standard browser to authorize at the original site rather than just using a web view to show the content within my app. However, every time they are directed to Safari (via openURL), it launches a new Safari window and once Safari has 8 windows open, it simply fails to work at all.
I'm wondering if there is an equivalen to the "target" attribute of an anchor tag in html which would allow me to cause all openURL calls from my application to open in the same window.
There is other functionality that I can expose via the web application, creating a hybrid app between native iphone functionality and web app functionality in Safari, but if I have to launch a new window every time I switch between the app and Safari, it becomes unworkable. The Youtube app is obviously able to return the user to the previous page after showing a video, but that might well be a custom plugin in Safari for iphone. Also, while returning to the previous page is somewhat useful, sending them to a new URL in the existing window really opens up a lot of possiblities.
I'm pretty sure there is no way to pass a target parameter to openURL:.
What I noticed about Safari is that it won't open another tab if the page you are opening with openURL: is/was already open in Safari. It just reloads that page. This might sound trivial and not helpful but perhaps you could use it to your advantage if you can make your web application only use one page. Different views or states could be expressed with #anchor tags.
An example is http://m.flickr.com. Notice their URL structure? It goes http://m.flickr.com/#/home, http://m.flickr.com/#/explore/interesting/, http://m.flickr.com/#/search and so on. All of these are different web pages to the user but to Safari it's all the same page.
I found iOS 6.0.1 Safari will open the same tab with a simple hashtag, without the slashes. So with the above example http://m.flickr.com, openURL to http://m.flickr.com#someinfo opens to the same tab.
In your webpage, use window.location.hash to return the params. In the above example it will return #someinfo.