我试图同时展示infowindow
两者marker
。
代码
-(void)set_markerOnMap:(double)lat longitude:(double)lon{
GMSMarker *marker = [[GMSMarker alloc] init];
marker.title = @"Location selected";
marker.position = CLLocationCoordinate2DMake(lat, lon);
marker.snippet = @"Testing";
marker.icon=[UIImage imageNamed:@"red-pin.png"];
marker.map = self.MyMapView;
[self.MyMapView setSelectedMarker:marker];
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self set_markerOnMap:21.214894 longitude:72.88087];
self.MyMapView.delegate=self;
}
上面的代码工作正常,它同时infowindow
显示marker
。但我的问题是当我调用set_markerOnMap
方法didTapAtCoordinate
而不是 viewDidLoad
它不起作用并且只marker
显示。
代码:
- (void)viewDidLoad
{
[super viewDidLoad];
self.MyMapView.delegate=self;
}
- (void) mapView: (GMSMapView *) mapView
didTapAtCoordinate: (CLLocationCoordinate2D) coordinate{
[self set_markerOnMap:21.214894 longitude:72.88087];
}
任何人都可以帮助我哪里错了?