Nhu*_*yen 6 google-maps objective-c ios
我用iOS Google Maps URL Scheme
打开Google Map
应用程序,我有schema
:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"comgooglemaps://?center=35.6653,139.6959&zoom=16&views=traffic&mapmode=standard"]];
Run Code Online (Sandbox Code Playgroud)
但是当我运行应用程序时,结果不会在位置显示标记(35.6653,139.6959).
如何显示标记?
小智 12
你可以像在网址中传递纬度和经度一样显示标记
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"http://maps.google.com/maps?q=35.6653,139.6959"]];
Run Code Online (Sandbox Code Playgroud)
在这里,您可以使用标记打开Google地图网站或Google地图应用.
- (void) onPositionPressed:(UITapGestureRecognizer*)sender{
NSNumber * latitude = [sender.view associativeObjectForKey:@"latitude"];
NSNumber * longitude = [sender.view associativeObjectForKey:@"longitude"];
if(latitude && longitude){
//Abrimos Google Maps...
if ([[UIApplication sharedApplication] canOpenURL:
[NSURL URLWithString:@"comgooglemaps://"]]) {
[[UIApplication sharedApplication] openURL:
[NSURL URLWithString:[NSString stringWithFormat:@"comgooglemaps://?q=%.6f,%.6f¢er=%.6f,%.6f&zoom=15&views=traffic", [latitude doubleValue], [longitude doubleValue], [latitude doubleValue], [longitude doubleValue]]]];
} else {
[[UIApplication sharedApplication] openURL:
[NSURL URLWithString:[NSString stringWithFormat:@"https://maps.google.com/maps?&z=15&q=%.6f+%.6f&ll=%.6f+%.6f", [latitude doubleValue], [longitude doubleValue], [latitude doubleValue], [longitude doubleValue]]]]; }
}
}
Run Code Online (Sandbox Code Playgroud)
在这些情况下,纬度和经度是NSNumbers,但你可以使用普通的双变量.
我希望这有助于任何人;)
归档时间: |
|
查看次数: |
3215 次 |
最近记录: |