iphone - Using Current Location from Location Manager in a Google Maps openURL? -
been looking while today can't seem head around how users current location google maps url open google maps app directions populated.
i've taken code tutorial , added app. need "start" lat/lng below ibaction open google maps app.
- (void)locationupdate:(cllocation *)location { // lat/lng of user (needs sent ibaction btndirections) cllocationcoordinate2d start = { location.coordinate.latitude, location.coordinate.longitude }; }
the below ibaction "get directions" button.
- (ibaction) onbuttonclick:(id) sender { if(sender == btndirections) { cllocationcoordinate2d destination = { 52.48306771095311, -1.8935537338256836 }; nsstring *googlemapsurlstring = [nsstring stringwithformat:@"http://maps.google.com/?saddr=%1.6f,%1.6f&daddr=%1.6f,%1.6f", newlocation.coordinate.latitude, newlocation.coordinate.longitude, destination.latitude, destination.longitude]; [[uiapplication sharedapplication] openurl:[nsurl urlwithstring:googlemapsurlstring]]; } }
i have done in app, view included map showing user location allowed me lat/lng easily.
thanks in advance.
simply pass "current+location" parameter google maps application:
http://maps.google.com/maps?saddr=current+location&daddr=heathrow+airport+london
Comments
Post a Comment