Map events

Implement any action you need to be triggered on one of the following map events:

  • Panning
  • Single press
  • Double press
  • Long press

To receive events you need to register id<TTMapViewDelegate> on map.

Sample use case: In your app, users invoke one behavior with a single press and another with a long press.

Use the following code snippets in your app to catch map events. In this example, the action is simply to display a toast with latitude and longitude on each map event. Of course, you can implement other cool features instead.

SWIFT
OBJECTIVEC
func mapView(_: TTMapView, didDoubleTap coordinate: CLLocationCoordinate2D) {
- (void)mapView:(TTMapView *)mapView didDoubleTap:(CLLocationCoordinate2D)coordinate {
SWIFT
OBJECTIVEC
func mapView(_: TTMapView, didSingleTap coordinate: CLLocationCoordinate2D) {
- (void)mapView:(TTMapView *)mapView didSingleTap:(CLLocationCoordinate2D)coordinate {
SWIFT
OBJECTIVEC
func mapView(_: TTMapView, didLongPress coordinate: CLLocationCoordinate2D) {
- (void)mapView:(TTMapView *)mapView didLongPress:(CLLocationCoordinate2D)coordinate {
SWIFT
OBJECTIVEC
func mapView(_: TTMapView, didPanning coordinate: CLLocationCoordinate2D, in state: TTMapPanningState) {
- (void)mapView:(TTMapView *)mapView didPanning:(CLLocationCoordinate2D)coordinate inState:(TTMapPanningState)state {
SWIFT
OBJECTIVEC
func mapView(_: TTMapView, onCenterStatusChanged _: TTMapCenteredState) {
- (void)mapView:(TTMapView *)mapView onCenterStatusChanged:(TTMapCenteredState)centeredState {
SWIFT
OBJECTIVEC
func mapView(_: TTMapView, onCameraChanged _: TTCameraPosition, with _: TTMapCameraChangeState) {
- (void)mapView:(TTMapView *)mapView onCameraChanged:(TTCameraPosition *)cameraPosition withState:(TTMapCameraChangeState)state {

In this example you will see that a Toast with the latitude and longitude of a point that was clicked on the map, but you can utilize this information in your own manner.

Receive callbacks after the map panning

Receive callbacks after the map panning

Receive callbacks after the map panning

Enable and disable gestures

You can disable gestures such as zooming, scrolling, and rotating in your application by setting up an integer mask on properties as shown in the following examples:

Disable zooming gesture

SWIFT
OBJECTIVEC
self.mapView.disableGesturesMask = TTOptionGesturesDisableZoom;
self.mapView.disableGesturesMask = .zoom;

Disable the rotating gesture

SWIFT
OBJECTIVEC
self.mapView.disableGesturesMask = .rotate;
self.mapView.disableGesturesMask = TTOptionGesturesDisableRotate;

Disable the scrolling gesture

SWIFT
OBJECTIVEC
self.mapView.disableGesturesMask = .scroll;
self.mapView.disableGesturesMask = TTOptionGesturesDisableScroll;

You can turn off more than one gesture by setting up the mask on properties as shown in the following examples:

SWIFT
OBJECTIVEC
self.mapView.disableGesturesMask = [.scroll, .zoom]
self.mapView.disableGesturesMask = TTOptionGesturesDisableScroll | TTOptionGesturesDisableZoom;

If you want to enable gestures, setup the integer mask on a property as shown in the following examples:

SWIFT
OBJECTIVEC
self.mapView.disableGesturesMask = .none;
self.mapView.disableGesturesMask = TTOptionGesturesDisableNone;