 |
 |
|
 |
12-21-2008, 12:33 PM
|
#1 (permalink)
|
|
Registered Member
Join Date: Aug 2008
Location: Germany, Munich
Posts: 230
|
Opening the maps app with a given route/direction
Hi,
i am trying to start the maps app with a given route (the direction/way should be drawn and visible):
Code:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"maps://maps.google.com/maps?saddr=48.09292914584927,11.76961898803711&daddr=48.09503592181566,11.76950097084045&z=17"]];
The zoom is ok and the destination address is visible in the right textbox. But the source adress is still empty. Am i missing something (wrong parameter name or direction)?
Cheers
Ralf
|
|
|
12-21-2008, 01:50 PM
|
#2 (permalink)
|
|
Registered Member
Join Date: Aug 2008
Location: Germany, Munich
Posts: 230
|
It seems that the second URL-Parameter (here daddr) will be ignored so maybe this is a syntax problem.
With the google maps web version the query is working very fine!
Ralf
Last edited by rhuettl; 12-21-2008 at 01:56 PM.
|
|
|
01-17-2009, 08:23 AM
|
#4 (permalink)
|
|
Registered Member
Join Date: Jul 2008
Location: Slovenia, EU
Posts: 254
|
Does anyone knows how to use maps URL scheme for driving directions from current location?
I tried by using "Current Location" as a source "saddr" quesry string but it does not recognize it as Current Location bookmark in Maps app. Anyone successfully done this?
this dosn't work
Code:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://maps.google.com/maps?daddr=Paris,+France&saddr=Current+Location"]];
Last edited by Jume; 01-17-2009 at 10:14 AM.
|
|
|
01-17-2009, 12:05 PM
|
#5 (permalink)
|
|
Senior Member
iPhone Dev SDK Supporter
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 2,575
|
Quote:
Originally Posted by Jume
Does anyone knows how to use maps URL scheme for driving directions from current location?
I tried by using "Current Location" as a source "saddr" quesry string but it does not recognize it as Current Location bookmark in Maps app. Anyone successfully done this?
|
Last time I researched this, it seemed you needed to get the current location from Core Location, and pass those lat/long in as the source address. There's no param in the map API for "current location."
__________________
|
|
|
01-17-2009, 05:55 PM
|
#6 (permalink)
|
|
Registered Member
Join Date: Jan 2009
Location: Silicon Valley, USA
Posts: 501
|
Quote:
Originally Posted by Jume
Does anyone knows how to use maps URL scheme for driving directions from current location?
|
Did you ever figure this out?
I've been able to get current location using the Apple LocateMe example. I've also been able to formulate a search for businesses near a specific lat/long via a URL passed to Google maps.
What I haven't figured out is:
1. How to pass the current location found to the source address
2. If multiple business results are found, let the user pick one that become the destination address for driving directions.
|
|
|
04-23-2009, 12:39 AM
|
#7 (permalink)
|
|
New Member
Join Date: Jan 2009
Posts: 28
|
Quote:
Originally Posted by rhuettl
It seems that the second URL-Parameter (here daddr) will be ignored so maybe this is a syntax problem.
|
hi rhuetti. i had the same problem. it turns out, indeed, that this has to do with the number or ordering of url parameters. i solved the problem by adding an extra "dummy" parameter at the beginning. really strange, but works!
Code:
href="maps://maps.google.com/maps?xyz=xyz&saddr=$lat,$lng&daddr=$iPhoneEndAddress"
hope this helps. on another note, i think you would use "http://" rather than "maps:" since your launching from within your app. mine happens to be a web link.
--brian
|
|
|
05-31-2009, 07:45 PM
|
#8 (permalink)
|
|
New Member
Join Date: Oct 2008
Posts: 16
|
Embedding
How about if I want to embed the route in my application.
Lets say Im build a "take me there" application, where you give a lat,lon and the app draws you the route.
I will put a UIWebView in my View and load a url, right?
How will that URL look?
Is there any pitfall I might be overlooking?
Thanks in advance
Gonso
|
|
|
06-02-2009, 05:57 PM
|
#9 (permalink)
|
|
New Member
Join Date: Jan 2009
Posts: 28
|
Quote:
Originally Posted by gonso75
How about if I want to embed the route in my application. -Gonso
|
if you want to embed the route in your application, you should use the 3.0 sdk. it would be very slow to pull it off with a web based map loaded into a webview.
|
|
|
06-08-2009, 04:35 AM
|
#10 (permalink)
|
|
Registered Member
Join Date: Jun 2009
Posts: 6
|
Opening the maps app with a given route/direction
You can do this by obtaining the latitude and longitude from CoreLocation, and then passing that into the maps URL. You can mix and match lat/lon and street addresses, which is what I do:
Code:
CLLocationCoordinate2D currentLocation = [self getCurrentLocation];
NSString* address = @"123 Main St., New York, NY, 10001";
NSString* url = [NSString stringWithFormat: @"http://maps.google.com/maps?saddr=%f,%f&daddr=%@",
currentLocation.latitude, currentLocation.longitude,
[address stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
This works on my iPhone (2.2.1), and I didn't need to add any dummy parameters to the URL. Just saddr (lat/lon) and daddr (address).
|
|
|
06-08-2009, 08:10 AM
|
#11 (permalink)
|
|
New Member
Join Date: Jan 2009
Posts: 28
|
Quote:
Originally Posted by n8r0n
You can do this by obtaining the latitude and longitude from CoreLocation, and then passing that into the maps URL.
|
this will work, but it will close your app completely and open the iphone maps app instead to display the route. if you want to use the iphone map within your app, you'll need to use the 3.0 sdk.
|
|
|
06-08-2009, 07:51 PM
|
#12 (permalink)
|
|
Registered Member
Join Date: Jun 2009
Posts: 6
|
Opening the maps app with a given route/direction
Quote:
Originally Posted by bpgillett
this will work, but it will close your app completely and open the iphone maps app instead to display the route. if you want to use the iphone map within your app, you'll need to use the 3.0 sdk.
|
That was the intent of the original post (see topic title). Using Maps does close your app. I was merely replying to the original poster, and Jume, that this worked for me on OS 2.2.1 (with specific code snippet).
|
|
|
06-12-2009, 03:34 AM
|
#13 (permalink)
|
|
Registered Member
Join Date: Jan 2009
Posts: 32
|
So is there any official way to show route/direction with 3.0 MapKit? I looked around the class references but didn't find anything useful. Apparently you need to draw the route yourself.
Given 2 points (destination / source), is there any way to retrieve the coordinates of the intermediate points in the route?
|
|
|
06-12-2009, 03:41 PM
|
#14 (permalink)
|
|
Registered Member
Join Date: Jun 2009
Posts: 6
|
Quote:
Originally Posted by mesohorny
So is there any official way to show route/direction with 3.0 MapKit? I looked around the class references but didn't find anything useful. Apparently you need to draw the route yourself.
Given 2 points (destination / source), is there any way to retrieve the coordinates of the intermediate points in the route?
|
Im at the same situation.
Ive found this: The Reluctant Blogger :: Drawing polyines or routes on a MKMapView (Using Map Kit on the iPhone)
But, where i can get this lat long about the route?
thks
|
|
|
09-16-2009, 05:41 AM
|
#15 (permalink)
|
|
Registered Member
Join Date: Jul 2009
Posts: 12
|
Hi did you find the solution? I am also searching for the same.
Thanks
|
|
|
09-16-2009, 08:17 AM
|
#16 (permalink)
|
|
Registered Member
Join Date: Jul 2008
Posts: 193
|
Bump! I have a feeling that there is no solution for this, but I would love it if route-finding is part of the mapkit API. Perhaps there's a way to get the route via the google API and then display it in mapkit using the technique in the link above?
- Charlie
|
|
|
10-04-2009, 05:29 PM
|
#17 (permalink)
|
|
Registered Member
Join Date: Jul 2008
Posts: 193
|
Using the technique from the above link, I've been able to draw a route in my MKMapView. However, it's taking quite a while to draw an redraw the route whenever the map is moved. I'm thinking that it might be better to just open the route in the maps app.
But, my route comes from a KML file as a series of gps coordinates. Is there a way to encode them into the URL that I use to open the maps app so that they appear as a route when the maps app opens?
- Charlie
|
|
|
10-08-2009, 09:47 AM
|
#18 (permalink)
|
|
Senior member
iPhone Dev SDK Supporter
Join Date: May 2009
Location: Lille, France
Posts: 32
|
some more
Hi
I have the same need
Is their something new ? I need to show the map with direction from actual position to known address ...
thanks
greg
|
|
|
10-08-2009, 06:15 PM
|
#19 (permalink)
|
|
Registered Member
Join Date: Mar 2009
Posts: 107
|
Quote:
Originally Posted by iKomobi
Hi
I have the same need
Is their something new ? I need to show the map with direction from actual position to known address ...
thanks
greg
|
Initialize corelocation, make sure you have the latitude and longitude of your current position, send it to the google maps app and it will open with the given route.
|
|
|
10-27-2009, 05:20 AM
|
#20 (permalink)
|
|
Senior member
iPhone Dev SDK Supporter
Join Date: May 2009
Location: Lille, France
Posts: 32
|
different behavior simulator / device
Quote:
Originally Posted by stuffradio
Initialize corelocation, make sure you have the latitude and longitude of your current position, send it to the google maps app and it will open with the given route.
|
thanks for your tips
I waste some time on it so just this information : the behavior is different on device and on simulator, I tested on 3.1.2. The map and information window is showned differently
greg
|
|
|
12-15-2009, 10:50 PM
|
#21 (permalink)
|
|
Registered Member
Join Date: Jun 2009
Posts: 6
|
Quote:
Originally Posted by Gregoire
thanks for your tips
I waste some time on it so just this information : the behavior is different on device and on simulator, I tested on 3.1.2. The map and information window is showned differently
greg
|
There is no Maps app in the simulator, so the simulator has to open Safari, pointing at google maps. The Apple documentation for the Maps URL scheme mentions this:
iPhone Dev Center: Apple URL Scheme Reference: Map Links
|
|
|
12-16-2009, 11:40 PM
|
#22 (permalink)
|
|
Registered Member
Join Date: Dec 2009
Posts: 1
|
Using this code in an iPhone optimized webpage
I am hoping to be able to implement the Core Location solution in my iPhone optimized web page so that paramedics can click on a link next to a hospital's name and get directions in Google Maps from their current location. How would I incorporate this as Javascript into the HTML; either inline or as part of an external javascript file?
Assistance on this would be greatly appreciated! The paramedics of Alameda County would be very thankful!!!!
-joshua the lorax
Test site link here
|
|
|
12-17-2009, 03:00 AM
|
#23 (permalink)
|
|
Registered Member
Join Date: Jun 2009
Posts: 6
|
Quote:
Originally Posted by lorax
I am hoping to be able to implement the Core Location solution in my iPhone optimized web page so that paramedics can click on a link next to a hospital's name and get directions in Google Maps from their current location. How would I incorporate this as Javascript into the HTML; either inline or as part of an external javascript file?
Assistance on this would be greatly appreciated! The paramedics of Alameda County would be very thankful!!!!
-joshua the lorax
Test site link here
|
Joshua,
I don't know if you can directly get the current location from the phone in a dynamic web page. See discussion here:
iPhone app that access the Core Location framework over web - Stack Overflow
or
Accessing the iPhone Location from a Webpage [splitbrain.org]
That's one advantage of the SDK. It gives you access to stuff like that. But, if you can get the current location (using one of the two techniques linked to above, or some other way), then you can use a web page like this:
Code:
<html>
<head>
<meta name="viewport" content="width=320"/>
<script language="javascript" type="text/javascript">
<!--
function mapTo(address) {
// put something more sophisticated here, if you don't want to hard-code the start coordinates:
window.open('http://maps.google.com/maps?saddr=47.58012312,-122.3459&daddr=' + address);
}
-->
</script>
</head>
<body>
Click on <a href="http://maps.google.com/maps?saddr=47.57164,-122.4096&daddr=4916+Erskine+Way+SW,+Seattle,+WA,+98116"> this link</a> to open the Maps app.
<br/>
Or click on <a href="#" onClick="javascript:mapTo('5040+Erskine+Way+SW,+Seattle,+WA,+98116');return false" >a more dynamic map link here</a>.
</body>
</html>
I put this page on my webserver, and tested it with my iPhone. Does this help?
|
|
|
 |
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
» Advertisements |
» Online Users: 375 |
| 32 members and 343 guests |
| amr8, Appency, appie, awesomeguys, bensj, bono_aem, BrianSlick, cje, computermatt, CunningCat, Dracor, dre, embedded, georgeburns, haza100, howardie08, Irishdawg90, jack_the_rat, JasonR, jmurff, jonn4y, jpatzer, kamau, kilobytedump, MarkC, meosoft, Oliver Drobnik, redon, rjgrune, SonaKily418, SPAS, yannickd60 |
| Most users ever online was 779, 05-11-2009 at 09:55 AM. |
» Stats |
Members: 24,308
Threads: 39,107
Posts: 171,455
Top Poster: smasher (2,575)
|
| Welcome to our newest member, howardie08 |
|