0

您如何区分单击鼠标单击和双击?我的单击侦听器似乎也捕获了所有双击:

tz定位器

这是 flash/flex API 的一个已知问题,但 js 解决方法似乎也不能同时处理这两个问题:code.google.com

4

1 回答 1

1

可能需要澄清一下,但请确保您使用的是 Google Map 的 MapMouseEvent,而不是 Flash API 的点击事件(请假设此代码在Map子类中):

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!")
    }
}
于 2009-01-13T04:42:18.893 回答