我想展示infowindow
and marker
两者同时进行。
code
-(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
and marker
一起。
但我的问题是当我打电话时set_markerOnMap
方法来自didTapAtCoordinate
代替viewDidLoad
它不起作用,只能marker
显示。
code:
- (void)viewDidLoad
{
[super viewDidLoad];
self.MyMapView.delegate=self;
}
- (void) mapView: (GMSMapView *) mapView
didTapAtCoordinate: (CLLocationCoordinate2D) coordinate{
[self set_markerOnMap:21.214894 longitude:72.88087];
}
任何人都可以帮助我,我哪里错了?
看看这是否有效...
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
[self set_markerOnMap:21.214894 longitude:72.88087];
}];
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)