How to embed the Google Maps iPhone app within my own native iphone application? -


the apple developer documentation explains if place link in web page , click whilst using mobile safari on iphone, google maps application provided standard iphone launch.

how can launch same google maps application specific address within own native iphone application (i.e. not web page through mobile safari) in same way tapping address in contacts launches map?

for ios 6.1.1 , lower, use openurl method of uiapplication. perform normal iphone magical url reinterpretation. so

[someuiapplication openurl:[nsurl urlwithstring:@"http://maps.google.com/maps?q=london"]] 

should invoke google maps app.

from ios 6, you'll invoking apple's own maps app. this, configure mkmapitem object location want display, , send openinmapswithlaunchoptions message. start @ current location, try:

[[mkmapitem mapitemforcurrentlocation] openinmapswithlaunchoptions:nil]; 

you'll need linked against mapkit (and prompt location access, believe).

you can use

uiapplication *app = [uiapplication sharedapplication]; [app openurl:[nsurl urlwithstring: @"http://maps.google.com/maps?q=london"]]; 

to open google maps @ specific co-ordinates, try this code:

nsstring *latlong = @"-56.568545,1.256281"; nsstring *url = [nsstring stringwithformat: @"http://maps.google.com/maps?ll=%@", [latlong stringbyaddingpercentescapesusingencoding:nsutf8stringencoding]]; [[uiapplication sharedapplication] openurl:[nsurl urlwithstring:url]]; 

you can replace latlong string current location corelocation.

you can specify zoom level, using (”z“) flag. values 1-19. here's example:

[[uiapplication sharedapplication] openurl:[nsurl         urlwithstring:@"http://maps.google.com/maps?z=8"]]; 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -