【发布时间】:2019-08-25 18:23:06
【问题描述】:
我正在尝试在运行时添加标记,然后按下按钮。按钮方法调用和代码运行,但地图上未显示标记。如果我在添加子视图时间时添加标记然后完美显示,但我需要在按钮按下时使用不同的大小写。
按钮点击(地图上不显示任何制造商)
-(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:@"pinIcon"];
london.map = self.mapView;
});
}
添加时间(显示标记)
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:self.currentLocation.coordinate.latitude
longitude:self.currentLocation.coordinate.longitude
zoom:16];
self.mapView = [GMSMapView mapWithFrame:self.view.frame camera:camera];
self.mapView.myLocationEnabled = YES;
[self.mapView setDelegate:self];
self.mapView.mapType = kGMSTypeSatellite;
[self.googleMapView addSubview:self.mapView];
self.marker = [[GMSMarker alloc] init];
self.marker.position = CLLocationCoordinate2DMake(43.649580, -79.385440);
self.marker.title = @"Toronto";
self.marker.snippet = @"Canada";
self.marker.map = self.mapView;
【问题讨论】:
-
什么是googleMapView?为什么要向其中添加 Google 地图视图?
-
ViewController 中的子视图。
-
和self.view一样
-
只有在 viewdidload 中你可以添加伦敦标记,但是当按钮按下标记应该被隐藏时它应该被隐藏,不要尝试这种方式
-
按下按钮后标记不显示的问题
标签: ios objective-c google-maps-api-3