Disabling double tap to zoom in Google Maps for iOS? - ios

I'm working on an app (iOS 7) which is using Google Maps (v1.8.1). I'm trying to implement a feature, where You would have a polygon in the map, and when you double tap it - it zooms to the polygon. I've read around that I could disable zooming gestures in the map, via googleMapView.settings.zoomGestures = NO;, but I don't want to lose zoomGestures at all (You can zoom in using double tap (when not double tapping on the polygon) or pinch to zoom). I've tried adding a GestureRecognizer, but the method for the recognizer gets called after the zoom happens (GMSMapViewDelegate method willMove gets called first). How would I go about this?

Related

Swift - GoogleMaps SDK get single or double finger tap gestures

I am using Google Maps SDK in my project. I want to check and detect when tap on google map that is used single finger or double finger ?
My requirement is, disable single finger use and enable double finger use. I want all Gestures work on double finger not on single finger.
First, disable all gesture on your GMSMapView instance. Documentation says:
You can disable the default gestures on the map by setting properties of the GMSUISettings class, which is available as a property of the GMSMapView
Source: https://developers.google.com/maps/documentation/ios-sdk/controls
Then you may be able to add some UITapGestureRecognizer:
Source: https://developer.apple.com/documentation/uikit/uitapgesturerecognizer
Don't forget to set numberOfTouchesRequired to 2 !
Source: https://developer.apple.com/documentation/uikit/uitapgesturerecognizer/1623580-numberoftouchesrequired

How to override three finger accessibility zoom gesture?

I am trying to create a gesture recognizer that responds to three touches, but the gesture is ignored if the user has the accessibility zoom feature enabled, which triggers off a three finger double tap.
My view uses massive UI elements, so zooming is not appropriate. Is there an api to disable the accessibility zoom so I can respond to a three finger tap?
You could try posting a UIAccessibilityPauseAssistiveTechnologyNotification though I believe this only refers to external ATs, and not to VoiceOver and Zoom features. Though I have not played around with it much.
EDIT: I just checked, the constant for disabling the zoom feature is not available in UIAccessibilityConstants.h. So this will not work, meaning there is no viable solution for this.

How to add custom floor plan for MapView with zoom and pan

I am developing an iOS app using swift. I need to show a custom floor plan which users can zoom and pan. Floor plan is an image which I need to set to a mapview instead of showing a world map. When zooming it should load images for particular levels. And also I have to show some pin pointers for some points. I do not want to show the current location.
MKMapView is the best option? Or is there anything else to achieve this?
You can use this example for start. It shows how to position floor plan on map. So you'll require in addition to implement delegates methods - func mapView(mapView:MKMapView regionDidChangeAnimated animated:Bool) or func mapView(mapView:MKMapView regionWillChangeAnimated animated:Bool) to determine current zoom level to change your image visible part (as soon as it's a tiled image).

Disable Google Map Movement on double tap in iOS

I am using the Google Maps SDK for my iOS App.
You can zoom in on the map using either of two gestures.
Double Tap
Double Tap -> Hold -> Drag Down
In the first way, the map zooms in, but the map shifts near to the position where I double tap.
While in the second method, the map zooms in staying at the current map centre.
I want to achieve the second type of behaviour(map staying on current centre rather than shifting) on the first gesture too. How do I go about it?
EDIT: Basically the behaviour should be same as the Official Google Map Double Tap.
This is a config item in GMSUISettings class, so you can access it on your GMSMapView object's 'settings' property like below,
Obj-C:
mapView.settings.allowScrollGesturesDuringRotateOrZoom = NO;
Swift 2.1:
mapView.settings.allowScrollGesturesDuringRotateOrZoom = false
I had to dig into their source code to find this config item, its not mentioned anywhere in the docs.
You can disable the default gestures on the map by setting properties of the GMSUISettings class, which is available as a property of the GMSMapView. The following gestures can be enabled and disabled programmatically. Note disabling the gesture will not limit programmatic access to the camera settings.
scrollGestures — controls whether scroll gestures are enabled or disabled. If enabled, users may swipe to pan the camera.
zoomGestures — controls whether zoom gestures are enabled or disabled. If enabled, users may double tap, two-finger tap, or pinch to zoom the camera. Note that double tapping may pan the camera to the specified point.
tiltGestures — controls whether tilt gestures are enabled or disabled. If enabled, users may use a two-finger vertical down or up swipe to tilt the camera.
rotateGestures — controls whether rotate gestures are enabled or disabled. If enabled, users may use a two-finger rotate gesture to rotate the camera.
In the below example, both pan and zoom gestures have been disabled.
(void)loadView {
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:1.285
longitude:103.848
zoom:12];
mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView_.settings.scrollGestures = NO;
mapView_.settings.zoomGestures = NO;
self.view = mapView_;
}

How to drag marker in google maps

I am using google maps in my app. I am using a single marker. I want two things
When I tap on any location on map, My marker should animated to that position automatically. I am successful in this.
When I Long tap on the marker, it should animate up and move with my touch. when i release the touch, it should drag there.
I am having problem in the 2nd case. I have set the draggable property of the marker to true. Nothing else code is written . When i long tap on it, instead of the marker, whole map along with map moved up and then marker move acc to my touch. When i release the touch whole map along with marker move down slightly.
Any Suggestions Please?
In GMSMapDelegate, these are the methods related to dragging.
- (void)mapView:(GMSMapView *)mapView didBeginDraggingMarker:(GMSMarker *)marker;
- (void)mapView:(GMSMapView *)mapView didEndDraggingMarker:(GMSMarker *)marker;
- (void)mapView:(GMSMapView *)mapView didDragMarker:(GMSMarker *)marker;
But you need to set marker draggable. By default, marker is not draggable.
marker.draggable=YES;
You have to press-and-hold on the marker before it will begin dragging.
I had also implemented this feature of dragable marker in google maps.
Now, according to your 2 point in question above, the up-down movement of map with marker on longpress and release, this is inbuilt feature of google maps library.
I think up-down movement of map along marker is to clearly show full marker to users when they long press o marker.
sometimes, marker icons are small which can be hidden by our fingers while long press and we can't see the marker to drag and place to another position.
To avoid this type of issue, google maps had added this feature.

Resources