Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

MGLMapViewDelegate is unable to block moving pinch gesture #9168

Closed

Description

@jmkiley

I am still able to change the map camera even when mapView:shouldChangeFromCamera:toCamera: returns false. I can pan using a pinching gesture.

Code to reproduce is based on the restricting panning example. Repro'ed with that example using Mapbox iOS SDK v3.5.4 and v3.6.0-beta.2.

class BlockingGesturesDelegateExample_Swift: UIViewController, MGLMapViewDelegate {
    
    private var colorado: MGLCoordinateBounds!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let mapView = MGLMapView(frame: view.bounds)
        mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
        mapView.delegate = self
        
        // Denver, Colorado
        let center = CLLocationCoordinate2D(latitude: 39.748947, longitude: -104.995882)
        
        // Starting point
        mapView.setCenter(center, zoomLevel: 10, direction: 0, animated: false)
        
        // Colorado's bounds
        let ne = CLLocationCoordinate2D(latitude: 40.989329, longitude: -102.062592)
        let sw = CLLocationCoordinate2D(latitude: 36.986207, longitude: -109.049896)
        colorado = MGLCoordinateBounds(sw: sw, ne: ne)
        
        view.addSubview(mapView)
 }

    func mapView(_ mapView: MGLMapView, shouldChangeFrom oldCamera: MGLMapCamera, to newCamera: MGLMapCamera) -> Bool {
     
        return false
  }
}

Activity

  1. added
    iOS
    on Jun 1, 2017
  2. self-assigned this
    on Jun 2, 2017
  3. added this to the ios-v3.6.0 milestone on Jun 2, 2017
  4. changed the title [-]Able to change camera when changes are disabled[/-] [+]MGLMapViewDelegate is unable to block tilt gesture[/+] on Jun 22, 2017
  5. 1ec5 commented on Jun 22, 2017

    @1ec5
    Contributor

    I can’t reproduce this issue on master (as of 40e4755), nor on the release-ios-v3.6.0-android-v5.1.0 branch (as of d373024). My attempted steps were to make the change below in iosapp, then go to zoom level 18 and perform a two-finger pan gesture in the simulator or on an iPhone 6.

    diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m
    index 29c5c6501..9c821bd2c 100644
    --- a/platform/ios/app/MBXViewController.m
    +++ b/platform/ios/app/MBXViewController.m
    @@ -1922,4 +1922,8 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
         }
     }
     
    +- (BOOL)mapView:(MGLMapView *)mapView shouldChangeFromCamera:(MGLMapCamera *)oldCamera toCamera:(MGLMapCamera *)newCamera {
    +    return NO;
    +}
    +
     @end
  6. 1ec5 commented on Jun 22, 2017

    @1ec5
    Contributor

    OK, I can reproduce on a device. To reproduce, pinch with two fingers. The map won’t zoom, but it will pan as the fingers move together or apart.

  7. removed this from the ios-v3.6.0 milestone on Jun 22, 2017
  8. changed the title [-]MGLMapViewDelegate is unable to block tilt gesture[/-] [+]MGLMapViewDelegate is unable to block moving pinch gesture[/+] on Jun 22, 2017
  9. assigned and unassigned on Jun 22, 2017
  10. added this to the ios-v3.6.0 milestone on Jun 22, 2017
  11. added 2 commits that reference this issue on Jun 22, 2017
    6899969
    eedd055
  12. 1ec5 commented on Jun 22, 2017

    @1ec5
    Contributor

    Fixed in #9344 on the release-ios-v3.6.0-android-v5.1.0 branch.

  13. added a commit that references this issue on Jul 5, 2017
    20a5ef6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugiOS

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions