Sorry, you need to enable JavaScript to visit this website.

Map events

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.

_

func mapView(_: TTMapView, didDoubleTap coordinate: CLLocationCoordinate2D) {
- (void)mapView:(TTMapView *)mapView didDoubleTap:(CLLocationCoordinate2D)coordinate {

 

_

func mapView(_: TTMapView, didSingleTap coordinate: CLLocationCoordinate2D) {
- (void)mapView:(TTMapView *)mapView didSingleTap:(CLLocationCoordinate2D)coordinate {

 

_

func mapView(_: TTMapView, didLongPress coordinate: CLLocationCoordinate2D) {
- (void)mapView:(TTMapView *)mapView didLongPress:(CLLocationCoordinate2D)coordinate {

 

_

func mapView(_: TTMapView, didPanning coordinate: CLLocationCoordinate2D, in state: TTMapPanningState) {
- (void)mapView:(TTMapView *)mapView didPanning:(CLLocationCoordinate2D)coordinate inState:(TTMapPanningState)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.

image

Receive callbacks after the map panning

image

Receive callbacks after the map panning

image

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

_

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

 

Disable the rotating gesture

_

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

 

Disable the scrolling gesture

_

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:

_

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:

_

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