如何在google maps for ios中向覆盖框架添加内容
我添加了一个带有切换按钮的飞入覆盖,如GoogleMapsSDK示例中所示。我找不到如何向框架添加内容,需要添加标题/名称区域,然后在下面添加描述框。我想知道怎么做,或者是否有其他方法我应该这样做 下面是上面的sdk示例: 这是我的MapViewController.m的代码如何在google maps for ios中向覆盖框架添加内容,ios,google-maps,overlay,Ios,Google Maps,Overlay,我添加了一个带有切换按钮的飞入覆盖,如GoogleMapsSDK示例中所示。我找不到如何向框架添加内容,需要添加标题/名称区域,然后在下面添加描述框。我想知道怎么做,或者是否有其他方法我应该这样做 下面是上面的sdk示例: 这是我的MapViewController.m的代码 #import "MapViewController.h" #import <GoogleMaps/GoogleMaps.h> static CGFloat kOverlayHeight = 180.0f;
#import "MapViewController.h"
#import <GoogleMaps/GoogleMaps.h>
static CGFloat kOverlayHeight = 180.0f;
@implementation MapViewController {
GMSMapView *mapView_;
UIView *_overlay;
__strong IBOutlet UIBarButtonItem *_flyInButton;
}
- (void)viewDidLoad {
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:39.901379 //Tony X
longitude:-105.007308 //Tony Y
zoom:18];
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView_.myLocationEnabled = YES;
mapView_.settings.myLocationButton = YES;
mapView_.padding = UIEdgeInsetsMake(0, 0, kOverlayHeight, 0);
mapView_.mapType = kGMSTypeHybrid;
self.view = mapView_;
_flyInButton = [[UIBarButtonItem alloc] initWithTitle:@"Toggle Overlay"
style:UIBarButtonItemStylePlain
target:self
action:@selector(didTapFlyIn)];
self.navigationItem.rightBarButtonItem = _flyInButton;
CGRect overlayFrame = CGRectMake(0, -kOverlayHeight, 0, kOverlayHeight);
_overlay = [[UIView alloc] initWithFrame:overlayFrame];
_overlay.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth;
_overlay.backgroundColor = [UIColor colorWithHue:0.0 saturation:0.0 brightness:0.0 alpha:0.9];
[self.view addSubview:_overlay];
/*GMSMarker *markerCaleb = [[GMSMarker alloc] init];
markerCaleb.position = CLLocationCoordinate2DMake(39.900747, -105.00773400000003); //Caleb X, Caleb Y
markerCaleb.title = @"Caleb's House";
markerCaleb.snippet = @"Denver, CO";
markerCaleb.map = mapView_; */
// Creates a marker in the center of the map.
GMSMarker *markerTony = [[GMSMarker alloc] init];
markerTony.position = CLLocationCoordinate2DMake(39.901379, -105.007308); //Tony X, Tony Y
markerTony.title = @"Mr. Tony's House";
markerTony.snippet = @"Denver, CO";
markerTony.map = mapView_;
}
- (void)didTapFlyIn {
UIEdgeInsets padding = mapView_.padding;
[UIView animateWithDuration:2.0 animations:^{
CGSize size = self.view.bounds.size;
if (padding.bottom == 0.0f) {
_overlay.frame = CGRectMake(0, size.height - kOverlayHeight, size.width, kOverlayHeight);
mapView_.padding = UIEdgeInsetsMake(0, 0, kOverlayHeight, 0);
} else {
_overlay.frame = CGRectMake(0, mapView_.bounds.size.height, size.width, 0);
mapView_.padding = UIEdgeInsetsZero;
}
}];
}
@end
#导入“MapViewController.h”
#进口
静态CGFloat-kOverlayHeight=180.0f;
@MapViewController的实现{
GMSMapView*地图视图;
UIView*_覆盖;
__强大的IBUIBarbuttonite*飞扣;
}
-(无效)viewDidLoad{
GMSCameraPosition*摄像机=[GMSCameraPosition摄像机拍摄纬度:39.901379//Tony X
经度:-105.007308//Tony Y
缩放:18];
地图视图=[GMSMapView地图WithFrame:CGRectZero相机:相机];
mapView_u2;.myLocationEnabled=是;
mapView_979;.settings.myLocationButton=是;
mapView_u2;.padding=UIEdgeInsetsMake(0,0,kOverlayHeight,0);
mapView_u2;.mapType=kGMSTypeHybrid;
self.view=mapView;
_flyInButton=[[UIBarButtonim alloc]initWithTitle:@“切换覆盖”
风格:uibarbuttonimstyleplain
目标:自我
动作:@selector(didTapFlyIn)];
self.navigationItem.RightBarButtonim=\u flyInButton;
CGRect OVERLYFRAME=CGRectMake(0,-kOverlayHeight,0,kOverlayHeight);
_overlay=[[UIView alloc]initWithFrame:overlayFrame];
_overlay.autoresizingMask=UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth;
_overlay.backgroundColor=[UIColor colorWithHue:0.0饱和度:0.0亮度:0.0 alpha:0.9];
[self.view addSubview:_overlay];
/*GMSMarker*markerCaleb=[[GMSMarker alloc]init];
markerCaleb.position=CLLocationCoordinate2DMake(39.900747,-105.007734000000003);//Caleb X,Caleb Y
markerCaleb.title=@“Caleb的房子”;
markerCaleb.snippet=@“科罗拉多州丹佛市”;
markerCaleb.map=mapView*/
//在地图的中心创建一个标记。
GMSMarker*markerTony=[[GMSMarker alloc]init];
markerTony.position=CLLocationCoordinate2DMake(39.901379,-105.007308);//托尼X,托尼Y
markerTony.title=@“托尼先生的房子”;
markerTony.snippet=@“科罗拉多州丹佛市”;
markerTony.map=mapView;
}
-(无效)Dittapflyin{
UIEdgeInsets padding=地图视图\填充;
[UIView animateWithDuration:2.0动画:^{
CGSize size=self.view.bounds.size;
如果(padding.bottom==0.0f){
_overlay.frame=CGRectMake(0,size.height-kOverlayHeight,size.width,kOverlayHeight);
mapView_u2;.padding=UIEdgeInsetsMake(0,0,kOverlayHeight,0);
}否则{
_overlay.frame=CGRectMake(0,mapView.bounds.size.height,size.width,0);
mapView_U2;.padding=UIEdgeInsetsZero;
}
}];
}
@结束
以下是我想要的视觉效果:
谢谢