Disable double left click on google map












27















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?










share|improve this question





























    27















    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?










    share|improve this question



























      27












      27








      27


      6






      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?










      share|improve this question
















      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?







      javascript google-maps google-maps-api-3






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Sep 11 '15 at 14:20









      Artjom B.

      52.9k1779145




      52.9k1779145










      asked Jul 6 '10 at 13:35









      davidleedavidlee

      1,392103861




      1,392103861
























          5 Answers
          5






          active

          oldest

          votes


















          108














          You can disable double-click zoom on Google Maps by setting the following google.maps.MapOptions object property:



          disableDoubleClickZoom: true


          Sample code:



          var mapOptions = {
          scrollwheel: false,
          disableDoubleClickZoom: true, // <---
          panControl: false,
          streetViewControl: false,
          center: defaultMapCenter
          };





          share|improve this answer





















          • 1





            Several of my questions answered in one here - love that :)

            – Darragh Enright
            Mar 9 '18 at 22:18



















          3














          You can take advantage of, dblclick fires if it is a double click, and single click fires in such occations only once.



          runIfNotDblClick = function(fun){
          if(singleClick){
          whateverurfunctionis();
          }
          };

          clearSingleClick = function(fun){
          singleClick = false;
          };

          singleClick = false;

          google.maps.event.addListener(map, 'click', function(event) {// duh! :-( google map zoom on double click!
          singleClick = true;
          setTimeout("runIfNotDblClick()", 500);
          });

          google.maps.event.addListener(map, 'dblclick', function(event) {// duh! :-( google map zoom on double click!
          clearSingleClick();
          });


          See http://www.ilikeplaces.com






          share|improve this answer

































            0














            You need an external var to do that :



             var isDblClick;
            google.maps.event.addListener(map, 'dblclick', function (event) {
            isDblClick = true;
            myDlbClickBelovedFunction();
            });

            google.maps.event.addListener(map, 'click', function (event) {
            setTimeout("mySingleClickBelovedFunction();;", 200);
            });

            function mySingleClickBelovedFunction() {
            if (!isDblClick) {
            // DO MY SINGLE CLICK BUSINESS :)
            }
            // DO NOTHING

            }





            share|improve this answer

































              0














              (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;
              });
              }





              share|improve this answer

































                -10














                It cannot be done, you would essentially have to block or prevent the event from happening.



                You could try something like createInterceptor() like in EXT JS. This would fire before the event is fired, and you can return false to prevent the actual event to fire, but I am not sure it will prevent the code from executing before the event is fired within that code.






                share|improve this answer























                  Your Answer






                  StackExchange.ifUsing("editor", function () {
                  StackExchange.using("externalEditor", function () {
                  StackExchange.using("snippets", function () {
                  StackExchange.snippets.init();
                  });
                  });
                  }, "code-snippets");

                  StackExchange.ready(function() {
                  var channelOptions = {
                  tags: "".split(" "),
                  id: "1"
                  };
                  initTagRenderer("".split(" "), "".split(" "), channelOptions);

                  StackExchange.using("externalEditor", function() {
                  // Have to fire editor after snippets, if snippets enabled
                  if (StackExchange.settings.snippets.snippetsEnabled) {
                  StackExchange.using("snippets", function() {
                  createEditor();
                  });
                  }
                  else {
                  createEditor();
                  }
                  });

                  function createEditor() {
                  StackExchange.prepareEditor({
                  heartbeatType: 'answer',
                  autoActivateHeartbeat: false,
                  convertImagesToLinks: true,
                  noModals: true,
                  showLowRepImageUploadWarning: true,
                  reputationToPostImages: 10,
                  bindNavPrevention: true,
                  postfix: "",
                  imageUploader: {
                  brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                  contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                  allowUrls: true
                  },
                  onDemand: true,
                  discardSelector: ".discard-answer"
                  ,immediatelyShowMarkdownHelp:true
                  });


                  }
                  });














                  draft saved

                  draft discarded


















                  StackExchange.ready(
                  function () {
                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f3186635%2fdisable-double-left-click-on-google-map%23new-answer', 'question_page');
                  }
                  );

                  Post as a guest















                  Required, but never shown

























                  5 Answers
                  5






                  active

                  oldest

                  votes








                  5 Answers
                  5






                  active

                  oldest

                  votes









                  active

                  oldest

                  votes






                  active

                  oldest

                  votes









                  108














                  You can disable double-click zoom on Google Maps by setting the following google.maps.MapOptions object property:



                  disableDoubleClickZoom: true


                  Sample code:



                  var mapOptions = {
                  scrollwheel: false,
                  disableDoubleClickZoom: true, // <---
                  panControl: false,
                  streetViewControl: false,
                  center: defaultMapCenter
                  };





                  share|improve this answer





















                  • 1





                    Several of my questions answered in one here - love that :)

                    – Darragh Enright
                    Mar 9 '18 at 22:18
















                  108














                  You can disable double-click zoom on Google Maps by setting the following google.maps.MapOptions object property:



                  disableDoubleClickZoom: true


                  Sample code:



                  var mapOptions = {
                  scrollwheel: false,
                  disableDoubleClickZoom: true, // <---
                  panControl: false,
                  streetViewControl: false,
                  center: defaultMapCenter
                  };





                  share|improve this answer





















                  • 1





                    Several of my questions answered in one here - love that :)

                    – Darragh Enright
                    Mar 9 '18 at 22:18














                  108












                  108








                  108







                  You can disable double-click zoom on Google Maps by setting the following google.maps.MapOptions object property:



                  disableDoubleClickZoom: true


                  Sample code:



                  var mapOptions = {
                  scrollwheel: false,
                  disableDoubleClickZoom: true, // <---
                  panControl: false,
                  streetViewControl: false,
                  center: defaultMapCenter
                  };





                  share|improve this answer















                  You can disable double-click zoom on Google Maps by setting the following google.maps.MapOptions object property:



                  disableDoubleClickZoom: true


                  Sample code:



                  var mapOptions = {
                  scrollwheel: false,
                  disableDoubleClickZoom: true, // <---
                  panControl: false,
                  streetViewControl: false,
                  center: defaultMapCenter
                  };






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Oct 9 '14 at 17:58









                  user664833

                  10.8k1766111




                  10.8k1766111










                  answered May 19 '11 at 8:15









                  Jatin DhootJatin Dhoot

                  2,75983254




                  2,75983254








                  • 1





                    Several of my questions answered in one here - love that :)

                    – Darragh Enright
                    Mar 9 '18 at 22:18














                  • 1





                    Several of my questions answered in one here - love that :)

                    – Darragh Enright
                    Mar 9 '18 at 22:18








                  1




                  1





                  Several of my questions answered in one here - love that :)

                  – Darragh Enright
                  Mar 9 '18 at 22:18





                  Several of my questions answered in one here - love that :)

                  – Darragh Enright
                  Mar 9 '18 at 22:18













                  3














                  You can take advantage of, dblclick fires if it is a double click, and single click fires in such occations only once.



                  runIfNotDblClick = function(fun){
                  if(singleClick){
                  whateverurfunctionis();
                  }
                  };

                  clearSingleClick = function(fun){
                  singleClick = false;
                  };

                  singleClick = false;

                  google.maps.event.addListener(map, 'click', function(event) {// duh! :-( google map zoom on double click!
                  singleClick = true;
                  setTimeout("runIfNotDblClick()", 500);
                  });

                  google.maps.event.addListener(map, 'dblclick', function(event) {// duh! :-( google map zoom on double click!
                  clearSingleClick();
                  });


                  See http://www.ilikeplaces.com






                  share|improve this answer






























                    3














                    You can take advantage of, dblclick fires if it is a double click, and single click fires in such occations only once.



                    runIfNotDblClick = function(fun){
                    if(singleClick){
                    whateverurfunctionis();
                    }
                    };

                    clearSingleClick = function(fun){
                    singleClick = false;
                    };

                    singleClick = false;

                    google.maps.event.addListener(map, 'click', function(event) {// duh! :-( google map zoom on double click!
                    singleClick = true;
                    setTimeout("runIfNotDblClick()", 500);
                    });

                    google.maps.event.addListener(map, 'dblclick', function(event) {// duh! :-( google map zoom on double click!
                    clearSingleClick();
                    });


                    See http://www.ilikeplaces.com






                    share|improve this answer




























                      3












                      3








                      3







                      You can take advantage of, dblclick fires if it is a double click, and single click fires in such occations only once.



                      runIfNotDblClick = function(fun){
                      if(singleClick){
                      whateverurfunctionis();
                      }
                      };

                      clearSingleClick = function(fun){
                      singleClick = false;
                      };

                      singleClick = false;

                      google.maps.event.addListener(map, 'click', function(event) {// duh! :-( google map zoom on double click!
                      singleClick = true;
                      setTimeout("runIfNotDblClick()", 500);
                      });

                      google.maps.event.addListener(map, 'dblclick', function(event) {// duh! :-( google map zoom on double click!
                      clearSingleClick();
                      });


                      See http://www.ilikeplaces.com






                      share|improve this answer















                      You can take advantage of, dblclick fires if it is a double click, and single click fires in such occations only once.



                      runIfNotDblClick = function(fun){
                      if(singleClick){
                      whateverurfunctionis();
                      }
                      };

                      clearSingleClick = function(fun){
                      singleClick = false;
                      };

                      singleClick = false;

                      google.maps.event.addListener(map, 'click', function(event) {// duh! :-( google map zoom on double click!
                      singleClick = true;
                      setTimeout("runIfNotDblClick()", 500);
                      });

                      google.maps.event.addListener(map, 'dblclick', function(event) {// duh! :-( google map zoom on double click!
                      clearSingleClick();
                      });


                      See http://www.ilikeplaces.com







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Apr 28 '11 at 15:02

























                      answered Apr 28 '11 at 14:50









                      Ravindranath AkilaRavindranath Akila

                      1174




                      1174























                          0














                          You need an external var to do that :



                           var isDblClick;
                          google.maps.event.addListener(map, 'dblclick', function (event) {
                          isDblClick = true;
                          myDlbClickBelovedFunction();
                          });

                          google.maps.event.addListener(map, 'click', function (event) {
                          setTimeout("mySingleClickBelovedFunction();;", 200);
                          });

                          function mySingleClickBelovedFunction() {
                          if (!isDblClick) {
                          // DO MY SINGLE CLICK BUSINESS :)
                          }
                          // DO NOTHING

                          }





                          share|improve this answer






























                            0














                            You need an external var to do that :



                             var isDblClick;
                            google.maps.event.addListener(map, 'dblclick', function (event) {
                            isDblClick = true;
                            myDlbClickBelovedFunction();
                            });

                            google.maps.event.addListener(map, 'click', function (event) {
                            setTimeout("mySingleClickBelovedFunction();;", 200);
                            });

                            function mySingleClickBelovedFunction() {
                            if (!isDblClick) {
                            // DO MY SINGLE CLICK BUSINESS :)
                            }
                            // DO NOTHING

                            }





                            share|improve this answer




























                              0












                              0








                              0







                              You need an external var to do that :



                               var isDblClick;
                              google.maps.event.addListener(map, 'dblclick', function (event) {
                              isDblClick = true;
                              myDlbClickBelovedFunction();
                              });

                              google.maps.event.addListener(map, 'click', function (event) {
                              setTimeout("mySingleClickBelovedFunction();;", 200);
                              });

                              function mySingleClickBelovedFunction() {
                              if (!isDblClick) {
                              // DO MY SINGLE CLICK BUSINESS :)
                              }
                              // DO NOTHING

                              }





                              share|improve this answer















                              You need an external var to do that :



                               var isDblClick;
                              google.maps.event.addListener(map, 'dblclick', function (event) {
                              isDblClick = true;
                              myDlbClickBelovedFunction();
                              });

                              google.maps.event.addListener(map, 'click', function (event) {
                              setTimeout("mySingleClickBelovedFunction();;", 200);
                              });

                              function mySingleClickBelovedFunction() {
                              if (!isDblClick) {
                              // DO MY SINGLE CLICK BUSINESS :)
                              }
                              // DO NOTHING

                              }






                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited Jan 16 '13 at 13:51

























                              answered Jan 16 '13 at 13:32









                              thennebellethennebelle

                              92




                              92























                                  0














                                  (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;
                                  });
                                  }





                                  share|improve this answer






























                                    0














                                    (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;
                                    });
                                    }





                                    share|improve this answer




























                                      0












                                      0








                                      0







                                      (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;
                                      });
                                      }





                                      share|improve this answer















                                      (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;
                                      });
                                      }






                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited Sep 11 '15 at 14:22

























                                      answered Sep 11 '15 at 13:22









                                      Václav ŠváraVáclav Švára

                                      964




                                      964























                                          -10














                                          It cannot be done, you would essentially have to block or prevent the event from happening.



                                          You could try something like createInterceptor() like in EXT JS. This would fire before the event is fired, and you can return false to prevent the actual event to fire, but I am not sure it will prevent the code from executing before the event is fired within that code.






                                          share|improve this answer




























                                            -10














                                            It cannot be done, you would essentially have to block or prevent the event from happening.



                                            You could try something like createInterceptor() like in EXT JS. This would fire before the event is fired, and you can return false to prevent the actual event to fire, but I am not sure it will prevent the code from executing before the event is fired within that code.






                                            share|improve this answer


























                                              -10












                                              -10








                                              -10







                                              It cannot be done, you would essentially have to block or prevent the event from happening.



                                              You could try something like createInterceptor() like in EXT JS. This would fire before the event is fired, and you can return false to prevent the actual event to fire, but I am not sure it will prevent the code from executing before the event is fired within that code.






                                              share|improve this answer













                                              It cannot be done, you would essentially have to block or prevent the event from happening.



                                              You could try something like createInterceptor() like in EXT JS. This would fire before the event is fired, and you can return false to prevent the actual event to fire, but I am not sure it will prevent the code from executing before the event is fired within that code.







                                              share|improve this answer












                                              share|improve this answer



                                              share|improve this answer










                                              answered Jul 20 '10 at 19:45









                                              CrazyEnigmaCrazyEnigma

                                              2,44111317




                                              2,44111317






























                                                  draft saved

                                                  draft discarded




















































                                                  Thanks for contributing an answer to Stack Overflow!


                                                  • Please be sure to answer the question. Provide details and share your research!

                                                  But avoid



                                                  • Asking for help, clarification, or responding to other answers.

                                                  • Making statements based on opinion; back them up with references or personal experience.


                                                  To learn more, see our tips on writing great answers.




                                                  draft saved


                                                  draft discarded














                                                  StackExchange.ready(
                                                  function () {
                                                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f3186635%2fdisable-double-left-click-on-google-map%23new-answer', 'question_page');
                                                  }
                                                  );

                                                  Post as a guest















                                                  Required, but never shown





















































                                                  Required, but never shown














                                                  Required, but never shown












                                                  Required, but never shown







                                                  Required, but never shown

































                                                  Required, but never shown














                                                  Required, but never shown












                                                  Required, but never shown







                                                  Required, but never shown







                                                  Popular posts from this blog

                                                  How to pass form data using jquery Ajax to insert data in database?

                                                  National Museum of Racing and Hall of Fame

                                                  Guess what letter conforming each word