我所做的是:
我把相机放在经度和纬度上 和同一位置的标记 我有两个问题 1)如何将它们置于当前位置 2)如何获得两点之间的路线- (void)viewDidLoad
{
[super viewDidLoad];
// maps
GMSCameraPosition *camera=[GMSCameraPosition cameraWithLatitude:40.714353 longitude:-74.005973 zoom:16];
mapview=[GMSMapView mapWithFrame:CGRectMake(100.0, 100.0, 140.0, 210.0) camera:camera];
mapview.myLocationEnabled=NO;
self.view=mapview;
GMSMarker *marker=[[GMSMarker alloc]init];
marker.position=CLLocationCoordinate2DMake(40.714353, -74.005973);
marker.title=@"chennai";
marker.map=mapview;
self.view=mapview;
// Do any additional setup after loading the view, typically from a nib.
}
请帮帮我
答案 0 :(得分:0)
您可以使用Google地图视图的 myLocation 属性获取当前位置。 首先启用 myLocation 。
mapview.myLocationEnabled=YES;
然后将位置设为
NSLog(@"%f %f",myLocation.coordinate.latitude, myLocation.coordinate.longitude);
marker.position = CLLocationCoordinate2DMake(myLocation.coordinate.latitude, myLocation.coordinate.longitude);
如果您想获得两点之间的指示,请按
进行申请http://maps.googleapis.com/maps/api/directions/output?parameters
参数为来源,目的地,传感器。 参考文件here
-(IBAction)getDirection {
NSURL *url = [ NSURL URLWithString: @"URL_STRING"];
NSURLRequest *req = [ NSURLRequest requestWithURL:url
cachePolicy:NSURLRequestReloadIgnoringCacheData
timeoutInterval:30.0 ];
NSError *err;
NSURLResponse *res;
NSData *d = [ NSURLConnection sendSynchronousRequest:req
returningResponse:&res
error:&err ];
}