google maps javascript api long press behaviour is broken down by zoom pinch -
i know there no "long press" event in google maps. somehow simulated behaviour using combination of other events. after pressing time, context menu appears options. however, in devices support of pinch zoom such tablets, after zoom in or out using 2 fingers, when stop touching device, menu unexpectedly appears. 2 concurrent touch events disturbs other one. suggestions appreciated. here relevant code :
var contextmenuoptions={}; contextmenuoptions.classnames={menu:'context_menu', menuseparator:'context_menu_separator'}; var menuitems=[]; menuitems.push({classname:'context_menu_item', eventname:'start_click', label:'from here'}); menuitems.push({classname:'context_menu_item', eventname:'end_click', label:'to here'}); menuitems.push({classname:'context_menu_item', eventname:'from_current_loc', label:'from location'}); menuitems.push({classname:'context_menu_item', eventname:'to_current_loc', label:'to location'}); // menuitems.push({classname:'context_menu_item', eventname:'center_map_click', label:'center map here'}); contextmenuoptions.menuitems=menuitems; // create contextmenu object var contextmenu=new contextmenu(map, contextmenuoptions); google.maps.event.addlistener(map, "mousedown", function(event){ contextmenu.hide(); sayac = settimeout(function(){ contextmenu.show(event.latlng); }, 500); }); // main refers map container document.getelementbyid("main").addeventlistener("touchend",function(){ cleartimeout(sayac); }); document.getelementbyid("main").addeventlistener("touchmove", function(){ cleartimeout(sayac); }); document.getelementbyid("main").addeventlistener("click",function(e){ e.preventdefault(); });
you can bind following events override tablet events , return inside handler.
google.maps.event.addlistener(map, "touchstart", function(e){ return; }); google.maps.event.addlistener(map, "touchend", function(e){ return; });
here can read more touchstart , touchend events.
Comments
Post a Comment