###前提・実現したいこと
Google Mapをタップするとマーカーが表示されます。
2つ目のマーカーが表示されたら1つ目のマーカーと線で繋ぐようにしたい。
###該当のソースコード
#import "ViewController.h" @interface ViewController () @end @implementation ViewController @synthesize gmapView; @synthesize marker; - (void)viewDidLoad { [super viewDidLoad]; float latitude = 35.172333; float longitude = 136.908351; float zoom = 15; // Google Mapsを表示 GMSCameraPosition *cameraPosition = [GMSCameraPosition cameraWithLatitude:latitude longitude:longitude zoom:zoom]; self.gmapView = [GMSMapView mapWithFrame:self.view.bounds camera:cameraPosition]; self.gmapView.myLocationEnabled = YES; self.gmapView.mapType = kGMSTypeSatellite; self.gmapView.delegate = self; [self.view addSubview:self.gmapView]; } /** * Google Maps タップ時デリゲートメソッド * @param GMSMapView mapView マップオブジェクト * @param CLLocationCoordinate2D coordinate タップ地点位置情報 */ -(void)mapView:(GMSMapView *)mapView didTapAtCoordinate:(CLLocationCoordinate2D)coordinate { NSLog(@"latitude:%f, longitude:%f", coordinate.latitude, coordinate.longitude); // マーカーを設定 self.marker = [[GMSMarker alloc] init]; //マーカーを移動させる marker.draggable = YES; marker.map = self.gmapView; // マーカーの色を変える self.marker.icon = [GMSMarker markerImageWithColor:[UIColor blueColor]]; // マーカーを任意の画像にする // self.marker.icon = [UIImage imageNamed:@"pin@3x.png"]; // マーカーを設置するマップを設定 self.marker.map = self.gmapView; // マーカーの設置アニメーションを設定 self.marker.appearAnimation = kGMSMarkerAnimationPop; self.marker.position = coordinate; } //ドラッグ開始 - (void)mapView:(GMSMapView *)mapView didBeginDraggingMarker:(GMSMarker *)marker; { } //ドラッグ中 - (void)mapView:(GMSMapView *)mapView didEndDraggingMarker:(GMSMarker *)marker; { } //ドラッグ終了 - (void)mapView:(GMSMapView *)mapView didDragMarker:(GMSMarker *)marker; { } @end
###補足内容
こちらに関する情報が見当たらなかったので質問させていただきました。
コードをどう書いたらいいのか分からずハマっております。
言葉足らずなとこもあるかと思いますがご教授頂ければと思います。
以上、よろしくお願い致します。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。