Disable double left click on google map

前端 未结 6 2106
清酒与你
清酒与你 2021-02-03 22:14

May I know how can I disable double click on google map so that the info window will not close when I double click on google map? Can it be done through google map api?

6条回答
  •  遇见更好的自我
    2021-02-03 23:00

    (Please consider that this is not answer, it is only same solution like Ravindranath Akila has been answering already, for using in wider ranges of solutions [eg. Mobile platforms] concentrated on one reusable method without global variables)

    We have similar trouble by Win 8.1 Mobile app. Thanks to Ravindranath Akila we finalized solution which is defined in one method and checking also zooming and moving with center of map. Anyway sometimes happened that the address we get from map-click is wrong - improvements are welcomed.

        // code
        { 
            // adding event method
            addGoogleClickEnventHandler(map, function(e) {
                // example code inside click event
                var clickLocation = e.latLng;
                getAddress(clickLocation);
            });
        }
    
        // function
        function addGoogleClickEnventHandler(googleEventableObject, handlingFunction) {
    
        var boundsChanged = false;
        var centerChanged = false;
        var singleClick = false;
    
        function runIfNotDblClick(obj) {
            if(singleClick && !boundsChanged && !centerChanged){
                handlingFunction(obj);
            }
        };
    
        googleEventableObject.addListener('bounds_changed', function () { boundsChanged = true; });
        googleEventableObject.addListener('center_changed', function () { centerChanged = true; });
        googleEventableObject.addListener('dblclick', function () { singleClick = false; });
    
        googleEventableObject.addListener('click', function(obj) {
           singleClick = true;
           setTimeout(function() {
                    runIfNotDblClick(obj);
                }, 200);            
            boundsChanged = false;
            centerChanged = false;
        });
        }
    

提交回复
热议问题