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 code snippets below 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(_ mapView: TTMapView, didDoubleTap coordinate: CLLocationCoordinate2D) {
- (void)mapView:(TTMapView *)mapView didDoubleTap:(CLLocationCoordinate2D)coordinate {

 

_

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

 

_

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

 

_

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

 

In this example you will see a Toast with latitude and longitude of a
point that was clicked on the map, but you can utilize these 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 like below:

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 like below:

_

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

 

If you want to enable gestures, setup the integer mask on a property like below:

_

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