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)?
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?
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."
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.
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!
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
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.
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).
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.
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).
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?
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?
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?
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?
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.
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
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:
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!!!!
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!!!!
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>