谷歌地图flex API:处理双击和单击?

时间:2009-01-08 02:38:13

标签: flex google-maps gis

如何通过双击单击鼠标?我的单身 click listener似乎也在捕获所有双击:

tz locator

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

1 个答案:

答案 0 :(得分: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!")
    }
}