【问题标题】:While Zooming and Pinching map , Google map is moving在缩放和捏地图时,谷歌地图正在移动
【发布时间】:2017-12-16 18:37:41
【问题描述】:

我已经提到了下面提到的所有内容,但没有任何帮助。我的要求是,如果我们双击或放大或缩小,地图和输入的图像不应像 Uber、Carrem 那样移动。我是 IOS 新手。我已经把代码放好了,谁能帮帮我,

Zoom in the center of the screen - Google Maps iOS SDK Swift Google Maps SDK iOS - prevent map from changing location on zoom How to setCenter mapview with location in google maps sdk for iOS

#import "ViewController.h"
#import <GoogleMaps/GoogleMaps.h>

@interface ViewController ()<UIGestureRecognizerDelegate,CLLocationManagerDelegate>

@end

@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
//To hide the default gestures
self.mapView.settings.allowScrollGesturesDuringRotateOrZoom=NO;
//self.mapView.settings.zoomGestures=NO;
//self.mapView.settings.rotateGestures=NO;

//After loading page camera will point this.
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:24.840216
                                                        longitude:46.676199
                                                             zoom:14];
[self.mapView animateToCameraPosition:camera];
self.mapView.settings.myLocationButton=TRUE;

//Make the image as center of the map

UIImageView *pin =[[UIImageView alloc]init];
pin.frame=CGRectMake(0, 0, 40, 40  );
pin.center = self.mapView.center;
pin.image = [UIImage imageNamed:@"location.png"];
[self.view addSubview:pin];
[self.view bringSubviewToFront:pin];

UIPanGestureRecognizer *doubleTab = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(didPan:)];
doubleTab.delegate=self;
//doubleTab.numberOfTapsRequired=2;
[self.mapView  addGestureRecognizer:doubleTab];



}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}


- (void) didPan:(UIPanGestureRecognizer*) gestureRecognizer
{
if (gestureRecognizer.state == UIGestureRecognizerStateEnded)
{
    NSLog(@"YES");
    self.mapView.settings.scrollGestures = YES;
}
}

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
if (gestureRecognizer.numberOfTouches > 1)
{
    NSLog(@"gestureRecognizer:NO");
    self.mapView.settings.scrollGestures = NO;
}
else
{
    NSLog(@"gestureRecognizer:YES");
    self.mapView.settings.scrollGestures = YES;
}
return true;
}

@end

【问题讨论】:

    标签: ios objective-c


    【解决方案1】:
    GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:1.285
                                                              longitude:103.848
                                                                   zoom:12];
      GMSMapView *mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
      mapView.settings.scrollGestures = NO;
      mapView.settings.zoomGestures = NO;
      self.view = mapView;
    

    【讨论】:

    • 感谢您的回复.. @iosdeveloperweb 你能告诉我我们必须在哪里做吗?
    • 感谢您的回复.. @iosdeveloperweb.wordpress.com 您能告诉我我们必须在哪里执行此操作吗? ——
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-10
    • 2016-07-09
    • 1970-01-01
    • 1970-01-01
    • 2012-11-06
    相关资源
    最近更新 更多