Ios 如何在objective c中的google地图上显示印度地图

Ios 如何在objective c中的google地图上显示印度地图,ios,objective-c,google-maps,Ios,Objective C,Google Maps,我是iOS新手,我面临在谷歌地图上显示印度地图的问题 我的代码是这样的 GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:18.516726 longitude:73.856255

我是iOS新手,我面临在谷歌地图上显示印度地图的问题 我的代码是这样的

 GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:18.516726
                                                            longitude:73.856255
                                                                 zoom:3];

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
    {
        //Scrollview
         mapView = [GMSMapView mapWithFrame:CGRectMake(10, 140, 750, 350) camera:camera];
    }
    else
    {
        //Scrollview
         mapView = [GMSMapView mapWithFrame:CGRectMake(10, 140, 550, 350) camera:camera];

    }
但是当我使用UIView并像这样使用IBMoutlet创建它时

IBOutlet GMSMapView *mapView;

以上代码无效。如何使用上述坐标首先显示印度地图。提前感谢

获取当前位置坐标并传递这些摄像机位置

CLLocationCoordinate2D coordinate;
float latitude;
float longitude;

coordinate = [self getLocation];
latitude = coordinate.latitude;
longitude = coordinate.longitude;
//pragma标记--:获取坐标2d:----


下面是一个示例代码:

#import <GoogleMaps/GoogleMaps.h>

@interface ViewController ()<GMSMapViewDelegate>
{
    GMSMapView *mapView;
    GMSMarker *marker;
}
@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self showMarker];    
}

- (void)showMarker
{
    GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:18.516726 longitude:73.856255 zoom:3];
    mapView_ = [GMSMapView mapWithFrame:self.view.bounds camera:camera];
    [self.view addSubview:mapView];
}

@end
#导入
@界面视图控制器()
{
GMSMapView*地图视图;
GMSMarker*标记;
}
@结束
@实现视图控制器
-(无效)viewDidLoad
{
[超级视图下载];
[自我表现];
}
-(无效)显示标记
{
GMSCameraPosition*摄像机=[GMSCameraPosition摄像机,纬度:18.516726经度:73.856255变焦:3];
地图视图=[GMSMapView-mapWithFrame:self.view.bounds-camera:camera];
[self.view addSubview:mapView];
}
@结束
尝试以下代码:

@interface ViewController ()<GMSMapViewDelegate>
{

    GMSMapView *mapView_;
}


GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:18.516726
                                                                    longitude:73.856255
                                                                         zoom:3];

            if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
            {
                //Scrollview
                mapView_ = [GMSMapView mapWithFrame:CGRectMake(10, 140, 750, 350) camera:camera];
            }
            else
            {
                //Scrollview
                mapView_ = [GMSMapView mapWithFrame:CGRectMake(10, 140, 550, 350) camera:camera];

            }


              NSError *error;

            // Set the map style by passing a valid JSON string.
            GMSMapStyle *style = [GMSMapStyle styleWithJSONString:kMapStyle error:&error];

            if (!style) {
                NSLog(@"The style definition could not be loaded: %@", error);
            }
            mapView_.mapStyle = style;
            mapView_.mapType = kGMSTypeNormal;

            [self.scrllView addSubview:mapView_];


            [_btnMap setTitleColor:[UIColor yellowColor] forState:UIControlStateNormal];

            mapView_.delegate = self;


            CLLocationCoordinate2D position = CLLocationCoordinate2DMake(
                                                                         18.516726,
                                                                         73.856255);


            GMSMarker *marker = [GMSMarker markerWithPosition:position];
            marker.map = mapView_;
            marker.icon=[UIImage imageNamed:@"locationBlue"];
            marker.title = @"From";
@界面视图控制器()
{
GMSMapView*地图视图;
}
GMSCameraPosition*摄像机=[GMSCameraPosition摄像机,纬度:18.516726
经度:73.856255
缩放:3];
if(UI\u USER\u INTERFACE\u IDIOM()==UIUserInterfaceIdiomPad)
{
//滚动视图
地图视图=[GMSMapView-mapWithFrame:CGRectMake(10140750350)摄影机:摄影机];
}
其他的
{
//滚动视图
地图视图=[GMSMapView-mapWithFrame:CGRectMake(10140550350)摄影机:摄影机];
}
n错误*错误;
//通过传递有效的JSON字符串来设置映射样式。
GMSMapStyle*style=[GMSMapStyle styleWithJSONString:kMapStyle错误:&error];
如果(!样式){
NSLog(@“无法加载样式定义:%@”,错误);
}
mapView_u2;.mapStyle=样式;
mapView_u2;.mapType=kGMSTypeNormal;
[self.scrlview addSubview:mapView_];
[\u btnMap setTitleColor:[UIColor yellowColor]用于状态:UIControlStateNormal];
mapView_.delegate=self;
CLLocationCoordinate2D位置=CLLocationCoordinate2DMake(
18.516726,
73.856255);
GMSMarker*marker=[GMSMarker marker with position:position];
marker.map=mapView;
marker.icon=[UIImage ImageName:@“locationBlue”];
marker.title=@“From”;

在情节提要中已有框架时,无需创建框架。为什么要创建它的框架?要创建属性吗?请显示您的故事板。@Priyal我需要添加如下的摄影机值mapView=[GMSMapView mapWithFrame:CGRectMake(10140750350)摄影机:摄影机];我正在使用.xib检查我的答案,你能告诉我什么是框架覆盖听力吗?请检查编辑CGRect frame=CGRectMake(0,0,k屏幕宽度,k屏幕高度);我刚刚使用了你的代码[mapView setCamera:camera];一切都结束了。谢谢你的帮助。
@interface ViewController ()<GMSMapViewDelegate>
{

    GMSMapView *mapView_;
}


GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:18.516726
                                                                    longitude:73.856255
                                                                         zoom:3];

            if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
            {
                //Scrollview
                mapView_ = [GMSMapView mapWithFrame:CGRectMake(10, 140, 750, 350) camera:camera];
            }
            else
            {
                //Scrollview
                mapView_ = [GMSMapView mapWithFrame:CGRectMake(10, 140, 550, 350) camera:camera];

            }


              NSError *error;

            // Set the map style by passing a valid JSON string.
            GMSMapStyle *style = [GMSMapStyle styleWithJSONString:kMapStyle error:&error];

            if (!style) {
                NSLog(@"The style definition could not be loaded: %@", error);
            }
            mapView_.mapStyle = style;
            mapView_.mapType = kGMSTypeNormal;

            [self.scrllView addSubview:mapView_];


            [_btnMap setTitleColor:[UIColor yellowColor] forState:UIControlStateNormal];

            mapView_.delegate = self;


            CLLocationCoordinate2D position = CLLocationCoordinate2DMake(
                                                                         18.516726,
                                                                         73.856255);


            GMSMarker *marker = [GMSMarker markerWithPosition:position];
            marker.map = mapView_;
            marker.icon=[UIImage imageNamed:@"locationBlue"];
            marker.title = @"From";