google maps - ContextMenu in GMap primefaces component -


does know how create primefaces contextmenu launched on right click on gmap?

normally code should this:

<p:gmap id="gmapelement" widgetvar="gmtls" center="41.381542, 2.122893" zoom="15" type="hybrid" styleclass="mapclass"/> <p:contextmenu for="gmapelement" >       <p:menuitem value="method a" onclick="method1()" />       <p:menuitem value="method b" onclick="method2()" />   </p:contextmenu>   

however, google api overrides right click event. think best way handle additional listener in google map. cannot find information how show context menu programatically:

var mapcomponent = gmtls.getmap(); google.maps.event.addlistener(mapcomponent, 'rightclick', function(mouseevent) {     //show context menu @ coordinates: mouseevent.latlng }); 

can tell me should put in listener body?

so here answer looking for. during initialisation of gmap component additional listener in google maps api must registered:

var mapcomponent = gmtls.getmap(); google.maps.event.addlistener(mapcomponent, 'rightclick', function(mouseevent) {     $(primefaces.escapeclientid('mainform:contextmenu')).css({         top: ypos+'px',         left: xpos+'px'                             }).show(); }); 

the easiest way coordinates (ypos, xpos) use jquery listen on mousemove event:

var xpos = 0; var ypos = 0; jquery(document).ready(function(){     $(document).mousemove(function(e){         xpos = e.pagex;         ypos = e.pagey;     });  }) 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -