【发布时间】:2015-01-28 08:32:30
【问题描述】:
我正在尝试同时显示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。
但我的问题是当我从didTapAtCoordinate 而不是viewDidLoad 调用set_markerOnMap 方法时,它不起作用,只显示marker。
代码:
- (void)viewDidLoad
{
[super viewDidLoad];
self.MyMapView.delegate=self;
}
- (void) mapView: (GMSMapView *) mapView
didTapAtCoordinate: (CLLocationCoordinate2D) coordinate{
[self set_markerOnMap:21.214894 longitude:72.88087];
}
任何人都可以帮助我哪里错了?
【问题讨论】:
标签: objective-c iphone google-maps ios7 gmsmapview