Googleマップで現在のマーカー位置の座標を選択する必要があります。マーカーが地図上を移動しているときに座標を更新するはずです。Googleマップで移動するマーカーのGPS座標を取得するiOS
私はGoogleマップ、GooglePlacesとGooglePlacePicker APIのを使用しています。 GooglePlacePicker APIを使用して近くの場所にアクセスできますが、マーカーが存在する場所の正確な座標を選択したいと考えています。
すでに完了しましたUber?
Googleマップで現在のマーカー位置の座標を選択する必要があります。マーカーが地図上を移動しているときに座標を更新するはずです。Googleマップで移動するマーカーのGPS座標を取得するiOS
私はGoogleマップ、GooglePlacesとGooglePlacePicker APIのを使用しています。 GooglePlacePicker APIを使用して近くの場所にアクセスできますが、マーカーが存在する場所の正確な座標を選択したいと考えています。
すでに完了しましたUber?
使用この、PLISTで
.H
@interface ViewController : UIViewController <CLLocationManagerDelegate> {
GMSMapView *mapView_;
GMSMarker *marker_;
float currentLatitude;
float currentLongitude;
}
@property(nonatomic,retain) CLLocationManager *locationManager;
@property (nonatomic)CLLocationCoordinate2D coordinate;
.M
- (void)viewDidLoad {
[super viewDidLoad];
_locationManager = [[CLLocationManager alloc] init];
[_locationManager setDelegate:self];
[_locationManager setDistanceFilter:kCLDistanceFilterNone];
[_locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
if (IS_OS_8_OR_LATER) {
if ([_locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
[_locationManager requestWhenInUseAuthorization];
}
}
[_locationManager startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
NSLog(@"%@",locations);
CLLocation *currentLoc=[locations objectAtIndex:0];
NSLog(@"CurrentLoc : %@",currentLoc);
_coordinate=currentLoc.coordinate;
currentLatitude = currentLoc.coordinate.latitude;
currentLongitude = currentLoc.coordinate.longitude;
}
-(void)plotMarkerForLatitude:(float)latitude andLongitude:(float)longitude {
// Now create maker on current location
if (marker_ == NULL) {
marker_ = [[GMSMarker alloc] init];
}
CLLocationCoordinate2D target =
CLLocationCoordinate2DMake(latitude, longitude);
marker_.position = target;
marker_.title = @"title";
marker_.appearAnimation = kGMSMarkerAnimationPop;
NSLog(@"%f %f",latitude,longitude);
marker_.icon = [UIImage imageNamed:@"marker"];
marker_.snippet = @"Address";
marker_.map = mapView_;
}
:
<key>NSLocationWhenInUseUsageDescription</key>
<string>Allow access to get your current location</string>
これはおそらくGMSMapViewDelegateプロトコルを実装することによって行うことができます。 guide to eventsとGMSMapViewDelegate
の方法のリストを参照してください。ドキュメントに述べたように
、
アプリケーションは、すべてのカメラの変更にコンテンツを再ロード、例えば、よりもむしろ、マーカー又はGMSMapViewに表示されている他のコンテンツのリフレッシュをトリガするためにこのイベントを使用することができます。
さらに、場所関連のアプリやサイトを構築するためにMaps iOS SDKとともに使用できる他のAPIについては、Google Maps SDK for iOSをチェックしてください。
返信いただきありがとうございます。私がムンバイに座っていて、GooglePlacePickerで移動するときにマーカーをニューヨークに移動するとします。私はニューヨークの座標を取得する必要がありますか? – Rains
はい、このコードは機能します。 –
結果はありますか? –