what i am trying to do by combining right click and popup menu is to add a menu to my right click event so that there will be two options as &quot;add point A&quot; and &quot;add point B&quot; in this menu. then, when the user selects either of them, i will add a marker with the correct letter. (as in google maps)<br>

<br>thanks all in advance,<br><br>BR<br><br><div class="gmail_quote">2012/5/7 ismet bahadir <span dir="ltr">&lt;<a href="mailto:ismetbahadir@gmail.com" target="_blank">ismetbahadir@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Hello All,<br><br>i was investigating how to add the popup menu to the right click event. as of now, i found a code piece so that i can capture the coordinate of right click. i also found &quot;OpenLayers.Popup&quot; function. however, when i use &quot;&quot;OpenLayers.Popup&quot;&quot; function, the popup appears on top of the map. instead, i want it to appear at mouse cursor when the user right clicks. <br>


<br>i think i need to combine the right click event with the popup creation but since i am a total newbie with coding, i cannot do it. can anyone help me?<br><br>thanks.<br><br>this is my code<br><br>----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<br>


<br>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&#39;en&#39;&gt;<br>&lt;head&gt;<br>&lt;meta charset=&#39;utf-8&#39; /&gt;<br>&lt;title&gt;ismetb map&lt;/title&gt;<br>&lt;script type=&#39;text/javascript&#39; src=&#39;OpenLayers.js&#39;&gt;&lt;/script&gt;<br>


&lt;script type=&#39;text/javascript&#39;&gt;<br><br>var map;<br><br>function init() {<br>map = new OpenLayers.Map(&#39;map_element&#39;, {});<br>var wms = new OpenLayers.Layer.WMS(<br>&#39;OpenLayers WMS&#39;,<br>&#39;<a href="http://vmap0.tiles.osgeo.org/wms/vmap0" target="_blank">http://vmap0.tiles.osgeo.org/wms/vmap0</a>&#39;,<br>


{layers: &#39;basic&#39;},<br>{}<br>);<br><br>map.addLayer(wms);<br>if(!map.getCenter()){<br>map.zoomToMaxExtent();<br>}<br>// Get control of the right-click event:<br>document.getElementById(&#39;map_element&#39;).oncontextmenu = function(e){<br>


  e = e?e:window.event;<br> if (e.preventDefault) e.preventDefault(); // For non-IE browsers.<br> else return false; // For IE browsers.<br>};<br><br><br>// A control class for capturing click events...<br>OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {                <br>


<br>defaultHandlerOptions: {<br>&#39;single&#39;: true,<br>&#39;double&#39;: true,<br>&#39;pixelTolerance&#39;: 0,<br>&#39;stopSingle&#39;: false,<br>&#39;stopDouble&#39;: false<br>},<br>handleRightClicks:true,<br>initialize: function(options) {<br>


this.handlerOptions = OpenLayers.Util.extend(<br>{}, this.defaultHandlerOptions<br>);<br>OpenLayers.Control.prototype.initialize.apply(<br>this, arguments<br>); <br>this.handler = new OpenLayers.Handler.Click(<br>this, this.eventMethods, this.handlerOptions<br>


);<br>},<br>CLASS_NAME: &quot;OpenLayers.Control.Click&quot;<br><br>});<br><br><br>// Add an instance of the Click control that listens to various click events:<br>var oClick = new OpenLayers.Control.Click({eventMethods:{<br>


&#39;rightclick&#39;: function(e) {<br>alert(&#39;rightclick at &#39;+e.xy.x+&#39;,&#39;+e.xy.y);<br>},<br>//&#39;click&#39;: function(e) {<br>//alert(&#39;click at &#39;+e.xy.x+&#39;,&#39;+e.xy.y);<br>//},<br>//&#39;dblclick&#39;: function(e) {<br>


//alert(&#39;dblclick at &#39;+e.xy.x+&#39;,&#39;+e.xy.y);<br>//},<br>//&#39;dblrightclick&#39;: function(e) {<br>//alert(&#39;dblrightclick at &#39;+e.xy.x+&#39;,&#39;+e.xy.y);<br>//}<br>}});<br>map.addControl(oClick);<br>


oClick.activate();<br><br>}<br><br> &lt;/script&gt;<br>&lt;/head&gt;<br><br>&lt;body onload=&#39;init();&#39;&gt;<br>&lt;div id=&#39;map_element&#39; style=&#39;width: 400px; height: 400px;&#39;&gt;<br>&lt;/div&gt;<br>&lt;/body&gt;<br>


&lt;/html&gt;<br><br>----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<br>


and this is popup example:<br><br><blockquote><pre><span>popup </span><span>=</span><span> </span><span>new</span><span> </span><span>OpenLayers</span><span>.</span><span>Popup</span><span>(</span><span>&quot;chicken&quot;</span><span>,</span><span><br>


                   </span><span>new</span><span> </span><span>OpenLayers</span><span>.</span><span>LonLat</span><span>(</span><span>5</span><span>,</span><span>40</span><span>),</span><span><br>
                   </span><span>new</span><span> </span><span>OpenLayers</span><span>.</span><span>Size</span><span>(</span><span>200</span><span>,</span><span>200</span><span>),</span><span><br>
                   </span><span>&quot;example popup&quot;</span><span>,</span><span><br>                   </span><span>true</span><span>);</span><span><br>
<br>map</span><span>.</span><span>addPopup</span><span>(</span><span>popup</span><span>);<br><br><br></span></pre></blockquote><br>
</blockquote></div><br>