我正在使用按钮在特定位置添加图钉,并且我的 map 已加载并显示在屏幕上。然后按下按钮没有响应,即使标记创建并分配坐标也是如此。
-(IBAction)addingMarkerOnMap:(id)sender
{
CLLocationCoordinate2D position = CLLocationCoordinate2DMake(51.5, -0.127);
GMSMarker *london = [GMSMarker markerWithPosition:position];
london.title = @"London";
london.icon = [UIImage imageNamed:@"Standard"];
london.map = self.mapView;
}
最佳答案
试试这个代码:
-(IBAction)addingMarkerOnMap:(id)sender
{
dispatch_async(dispatch_get_main_queue(), ^{
CLLocationCoordinate2D position = CLLocationCoordinate2DMake(51.5, -0.127);
GMSMarker *london = [GMSMarker markerWithPosition:position];
london.title = @"London";
london.icon = [UIImage imageNamed:@"Standard"];
london.map = self.mapView;
});
}
关于ios - 添加后 GMSMarker 未显示在 map 上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55241174/