views:

983

answers:

1

how do you tell a single mouse click from a double click? my single click listener seems to be trapping all the double clicks as well:

tz locator

it's a known issue for the flash/flex API but the js workaround doesn't seem to handle both either: code.google.com

+1  A: 

Might need a bit of clarification, but make sure you are using the Google Map's MapMouseEvent, not the Flash API's click events (please assume this code in inside a Map subclass):

public class GoogleMap extends Map 
{
    import com.google.maps.LatLng;
    import com.google.maps.Map;
    import com.google.maps.MapEvent;
    import com.google.maps.MapMouseEvent;

    public function GoogleMap():void
    {
     super();
     this.key = "YOUR_API_KEY";

     addEventListener(MapEvent.MAP_READY, _onMapReady);
        addEventListener(MapMouseEvent.CLICK, _onMapClick);
        addEventListener(MapMouseEvent.DOUBLE_CLICK, _onMapDoubleClick);
    }

    protected function _onMapClick(event:MapMouseEvent):void 
    {  
     trace("single!");
        var mousePoint:Point = new Point(mouseX, mouseY);
        var mousePointLocal:Point = globalToLocal(mousePoint);
        var mouseLatLng:LatLng = this.fromViewportToLatLng(mousePointLocal); 
    }

    protected function _onMapDoubleClick(event:MapMouseEvent):void 
    {
     trace("double!");
    }

    protected function _onMapReady(event:MapEvent):void 
    {
     trace("ready!")
    }
}
Typeoneerror