私は小さな問題があります。 ユーザーがアドレスを検索すると、アドレスが存在する場合はマーカーをズームして、別の色を付けたいと思います。 私はこれを使用しようとしています:https://developers.google.com/maps/documentation/ios-sdk/marker しかし成功することはできません。iOSアプリで既存のGoogleマップマーカーを変更するにはどうすればよいですか?
ここで私はマップ上のすべてのマーカーを置く:
ここPFQuery *query = [PFQuery queryWithClassName:@"Test2"];
[query selectKeys:@[@"googlid"]];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
NSLog(@" objects : %@", objects);
for (NSDictionary *dic in objects) {
NSString *placeID = [dic valueForKey:@"googlid"];
_placesclient = [[GMSPlacesClient alloc] init];
[_placesclient
lookUpPlaceID:placeID
callback:^(GMSPlace *place, NSError *error) {
if (error != nil) {
NSLog(@"Place Details error %@",
[error localizedDescription]);
return;
}
if (place != nil) {
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(
place.coordinate.latitude, place.coordinate.longitude);
marker.title = place.name;
marker.snippet = @"Push to see feedbacks";
marker.map = _mapview;
} else {
NSLog(@"No place details for %@", placeID);
}
}];
}
を私はマーカーを変更しよう:
if (exist) {
UIAlertController *alert = [UIAlertController
alertControllerWithTitle:nil
message:nil
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *exist =
[UIAlertAction actionWithTitle:@"Place exist"
style:UIAlertActionStyleDefault
handler:nil];
GMSCameraPosition *camera = [GMSCameraPosition
cameraWithLatitude:place.coordinate.latitude
longitude:place.coordinate.longitude
zoom:15];
self.mapview.camera = camera;
_targetMarker = [GMSMarker markerWithPosition:CLLocationCoordinate2DMake(
place.coordinate.latitude, place.coordinate.longitude)];
_targetMarker.map = _mapview;
_targetMarker.icon = [GMSMarker markerImageWithColor:[UIColor blackColor]];
実際にはどうなりますか?なぜアラートを作成しますが、それを使用しないのですか? – rmaddy
私はそれを使って、その場所が存在することをユーザーに警告します。 次に、それを表現するマーカーを表示して、色を変更したいと考えています。 – ironRoei