今天一顿复制粘贴将百度地图集成到项目当中了,但还是出了一点问题,经过上网查找答案和咨询朋友,还是解决了.在此,也感谢自从我工作以来帮助过我的人,谢谢,因为我知道没有任何一个人有义务无私帮你的,别人愿意帮你,都应感到幸运和心怀感激.
需求描述:A(tableviewVC)->push->B(普通VC),A push 到B,在B中获得坐标数据传给A,刷新A cell上的地图视图位置
问题描述:B能传坐标给A了,但A cell上的地图视图怎么都刷新不了
问题思考:请教了一个小姐姐,小姐姐说:"可能是其他的cell 做了其他的操作导致线程没走setCenterCoordinate 方法",(感谢,后面还发现小姐姐竟然和我一个城市,世界真小)
问题解决:在取得坐标的时候,延时设置地图中心点,
NSLog(@"onClickedMapBlank-latitude========%f,longitude=======%f",centerCoordinate.latitude,centerCoordinate.longitude);
//移除大头针
[_mapView removeOverlays:mapView.overlays];
[_mapView removeAnnotations:_mapView.annotations];
//添加一个PointAnnotation
_annotation = [[BMKPointAnnotation alloc]init];
CLLocationCoordinate2D coor;
coor.latitude = centerCoordinate.latitude;
coor.longitude = centerCoordinate.longitude;
_annotation.coordinate = coor;
[_mapView addAnnotation:_annotation];
//延时0.5秒为了刷新地图视图
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[_mapView setCenterCoordinate:coor animated:YES];
});
这样,地图就能刷新了
祝大家问题都能解决!加油加油