Cordova Phonegap and Google Maps v3 javascript api: How to add backbutton functionality when clicking either the license link or the Google maps logo

后端 未结 3 2059
囚心锁ツ
囚心锁ツ 2021-01-13 09:39

Background: The Cordova phonegap 2.2 application running on Android allows listening to the backbutton event

document.addEventListener(\"bac         


        
3条回答
  •  爱一瞬间的悲伤
    2021-01-13 09:47

    Here is one way to intersect the google maps links.

    Assuming you have jquery available, you can include this method in your script:

    function directUrlToExternalBrowser(urlPattern) {
      var pattern = "a[href^='"+urlPattern+"']";//all urls startting with urlPattern
      $(pattern).live('click', function(e){
          e.preventDefault();
          navigator.app.loadUrl($(pattern).attr("href"), {openExternal: true});
      });
    }
    

    Then you can direct the clicks to the phonegap api by the following lines:

    directUrlToExternalBrowser("http://maps.google.com/maps");
    directUrlToExternalBrowser("http://www.google.com/intl");
    

提交回复
热议问题