このコードを使用して、iOS 用の Google マップにマーカーを作成します。
self.mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
self.mapView.myLocationEnabled = YES;
self.mapView.accessibilityElementsHidden = NO;
self.mapView.frame = self.view.bounds;
self.mapView.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.mapView.delegate = self;
self.mapView.settings.myLocationButton = YES;
[self.view addSubview:self.mapView];
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(-33.86, 151.20);
marker.map = self.mapView;
しかし、マーカーを次のようにする必要があります。
Apple Map でそれを行う方法は知っていますが、Google Map を使用する必要があります (一部の都市では Apple Map ではほとんど何も表示されないため)。
Googleマップの場合、次のようなコードのみが見つかりました:
marker.icon = image; // image from xib file
そのため、マーカーごとに xib から画像を作成する必要があります。マーカーがたくさんあるので、このアプローチではメモリ警告が表示される可能性があります。
そのようなマーカーを実装するより良い方法を知っている人はいますか?