0

I am working on an application which is using ammaps. I have a number of points located on the map based on longitude and latitude value. I have achieved single click functionality by using the following code:

map.addListener("clickMapObject", function (event) {
                        $scope.$apply(function(){
                            $scope.colorPoints();
                            $scope.selectedRow = event.mapObject.idBase;
                        });
                });

I want to achieve the functionality of double click. Could anyone let me know how I could do that in amMaps.

1 Answer 1

1

Technically, amMap does not support double-click events. However, you can simulate it with a clickMapObject event.

For that you'll need to ignore the first click. If the subsequent clickMapObject happens within 500ms or so, you register it as double-click.

Something like this:

map.addListener( "clickMapObject", function( event ) {
  if ( false !== map.clickedObject && map.clickedObject === event.mapObject ) {
    // doubleckick
    map.clickedObject = false;
    $scope.$apply( function() {
      $scope.colorPoints();
      $scope.selectedRow = event.mapObject.idBase;
    } );
  } else {
    clearTimeout( map.clickedObjectTimeout );
    map.clickedObject = event.mapObject;
    map.clickedObjectTimeout = setTimeout( function() {
      map.clickedObject = false;
    }, 500 );
  }
} );
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.