2017-08-31 8 views
-1

私はプロジェクトを開発しており、Google Maps APIを使用しています。 携帯端末で問題が発生しています。モバイルのコンテキストメニューは長いタップでは機能しません。Google Maps API

google.maps.event.addListener(this.map, 'rightclick', function(e) { 
    if (options.rightclick) { 
    options.rightclick.apply(this, [e]); 
    } 

    if(window.context_menu[self.el.id]['map'] != undefined) { 
    self.buildContextMenu('map', e); 
    } 
}); 

がこれをどのように修正:​​-

私も

サンプルコードを右クリック(ロングタップイベントを)動作しませんGMaps.js 例を使用していますか?

答えて

0

の長いクリックをシミュレートして問題を解決します。 befor:

/** 
    * Start TIMER open context menu 
    */ 
    google.maps.event.addListener(this.map, 'mousedown', function(e) { 
     var context_menu_element = getElementById('gmaps_context_menu'); 

     document.pressTimer = window.setTimeout(function() { 
      jQuery(context_menu_element).addClass('mouse_tap'); 

      if (options.rightclick) { 
       options.rightclick.apply(this, [e]); 
      } 

      if (window.context_menu[self.el.id]['map'] != undefined) { 
       self.buildContextMenu('map', e); 
      } 
     },1000); 
     return false; 
    }); 


    /** 
    * Stop TIMER, and safe open or close context menu 
    */ 
    google.maps.event.addListener(this.map, 'mouseup', function() { 
     var context_menu_element = getElementById('gmaps_context_menu'); 

     if (jQuery(context_menu_element).hasClass('mouse_tap')){ 
      setTimeout(function() { 
       context_menu_element.style.display = 'block'; 
      }, 0); 

      jQuery(context_menu_element).removeClass('mouse_tap'); 
     } else { 
      this.hideContextMenu; 
     } 

     clearTimeout(document.pressTimer); 
     return false; 
    }); 

    /** 
    * if we move the map - cancel the opening of the context menu 
    */ 
    var context_menu_with_mouse = ['drag', 'dragend', 'dragstart']; 
    for (var ev = 0; ev < context_menu_with_mouse.length; ev++) { 
     (function (object, name) { 
      google.maps.event.addListener(object, name, function() { 
       clearTimeout(document.pressTimer); 
       jQuery(getElementById('gmaps_context_menu')).removeClass('mouse_tap').css('display', 'none'); 
       return false; 
      }); 
     })(this.map, context_menu_with_mouse[ev]); 
    } 

google.maps.event.addListener(this.map, 'rightclick', function (e) { 

は、コードを挿入

関連する問題