在缩放和捏合地图时,谷歌地图正在发生变化

问题描述 投票:1回答:1

我已经提到了下面提到的所有内容,但没有任何帮助。我的要求是如果我们加倍标签或放大或缩小,地图和输入的图像不应该像优步,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个回答
0
投票
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;
© www.soinside.com 2019 - 2024. All rights reserved.