How do I open an address in the Maps app from Corona?

I need to be able to pass a location to the new Apple Maps app (or Google Maps app if < iOS 6.) so users can route their location to the address. How can I open an address in the Maps application from within the Corona SDK? [import]uid: 64538 topic_id: 31357 reply_id: 331357[/import]

Something like this:

 local currentLocation = myMap:getUserLocation()  
 local currentLatitude = currentLocation.latitude  
 local currentLongitude = currentLocation.longitude  
 fromLoc = currentLatitude..","..currentLongitude  
 toLoc = Location  
 url = "http://maps.google.com/maps?saddr="..fromLoc.."&daddr="..toLoc  
 system.openURL( url )   

[import]uid: 50459 topic_id: 31357 reply_id: 125435[/import]

Thanks rmbsoft, I’d have NEVER thought to do it that way! I’m going to try that, then suggest that this be added to the mapping documentation so others can see how to do this! :slight_smile: [import]uid: 64538 topic_id: 31357 reply_id: 125441[/import]

I was able to get that to work on Android, but doesn’t work on iOS. Probably because I’m now on iOS 6 and there is no longer a google maps for it.

Anyone have an idea on how to do this with the new Apple Maps, yet also make it backwards compatible for users on iOS < iOS 6?

[import]uid: 64538 topic_id: 31357 reply_id: 125457[/import]

Try this:

url = “http://maps.apple.com/maps?saddr="..fromLoc.."&daddr=”…toLoc

Not tested :slight_smile:

[import]uid: 50459 topic_id: 31357 reply_id: 125460[/import]

I could test it, but the main issue I’d have is that how would I know to call it vs. Google Maps?

Again, not tested, but would I have to check for system.platformVersion >= “6.0” ? [import]uid: 64538 topic_id: 31357 reply_id: 125463[/import]

Never used it before, but i would use system.getInfo( “platformVersion” ) to figure out what version of iOS the device is running, and use google.maps.com versus apple.maps.com depending on the result.

I don’t know what the format is you’re getting, but you need to find the Major version, like 4, 5 or 6.

[import]uid: 50459 topic_id: 31357 reply_id: 125465[/import]

Something like this:

 local currentLocation = myMap:getUserLocation()  
 local currentLatitude = currentLocation.latitude  
 local currentLongitude = currentLocation.longitude  
 fromLoc = currentLatitude..","..currentLongitude  
 toLoc = Location  
 url = "http://maps.google.com/maps?saddr="..fromLoc.."&daddr="..toLoc  
 system.openURL( url )   

[import]uid: 50459 topic_id: 31357 reply_id: 125435[/import]

Thanks rmbsoft, I’d have NEVER thought to do it that way! I’m going to try that, then suggest that this be added to the mapping documentation so others can see how to do this! :slight_smile: [import]uid: 64538 topic_id: 31357 reply_id: 125441[/import]

I was able to get that to work on Android, but doesn’t work on iOS. Probably because I’m now on iOS 6 and there is no longer a google maps for it.

Anyone have an idea on how to do this with the new Apple Maps, yet also make it backwards compatible for users on iOS < iOS 6?

[import]uid: 64538 topic_id: 31357 reply_id: 125457[/import]

Try this:

url = “http://maps.apple.com/maps?saddr="..fromLoc.."&daddr=”…toLoc

Not tested :slight_smile:

[import]uid: 50459 topic_id: 31357 reply_id: 125460[/import]

I could test it, but the main issue I’d have is that how would I know to call it vs. Google Maps?

Again, not tested, but would I have to check for system.platformVersion >= “6.0” ? [import]uid: 64538 topic_id: 31357 reply_id: 125463[/import]

Never used it before, but i would use system.getInfo( “platformVersion” ) to figure out what version of iOS the device is running, and use google.maps.com versus apple.maps.com depending on the result.

I don’t know what the format is you’re getting, but you need to find the Major version, like 4, 5 or 6.

[import]uid: 50459 topic_id: 31357 reply_id: 125465[/import]

Is there a way to do this, but with an address instead of GPS coordinates? I’m trying to build a “map it” button to see someone’s address on Google Maps, then they could use Google Maps to get directions. [import]uid: 150151 topic_id: 31357 reply_id: 133399[/import]

Is there a way to do this, but with an address instead of GPS coordinates? I’m trying to build a “map it” button to see someone’s address on Google Maps, then they could use Google Maps to get directions. [import]uid: 150151 topic_id: 31357 reply_id: 133399[/import]