URL with Current Location to Google Maps from iPad fails
I am trying to create a URL that takes a user from where they are currently to any destination and provides directions. The URL below works fine in iOS on the iPhone, but does not on the iPad as it prompts be to clarify what Current Location is:
http://maps.google.com/maps?saddr=Current%20Location&daddr=350 Broadway,%20New%20York,%20New%20York
How can I make this work in both the iPhone 开发者_JS百科and the iPad?
I've Research this but...
I have researched about this for a while, and I believe there is no way to specify Current Location
. I know passing Current Location
as a parameter on iPhone works, but it is recognized as string Current Location rather than what you are intended.
Alternative Way
The alternative way is to get the coordinate of the user using Core Location
, and then pass this coordinate as saddr
parameter.
It may be a bit ugly on Maps app because there will be an annotation that indicates the user's current location and another pin annotation that indicates the coordinate you passed.
How to Get the Current User Location
Here's a post for getting the user location. What's the easiest way to get the current location of an iPhone?
It's actually very simple, the Google Maps API documentation says to simply leave saddr
blank and that will cause it to use "Current Location" as the starting point for your Directions request.
Like this:
comgooglemaps://?saddr=&daddr=1600+Amphitheatre+Parkway,+Mountain+View,+CA+94043
精彩评论