How to make 0penLayers right-click support?

Dear all,

Hi, I have looked through the develop document and tried and tried, but I still can’t make a right click menu in OpenStreetMap. Any of your suggetion is highly appreciated.

Thank you.


I would ask on the OpenLayers mailinglist.

Thanks emj, thank you. I have figured it out. The code works on my web mashup.

function init() {
map = new OpenLayers.Map (“map”, {
new OpenLayers.Control.Navigation(),
new OpenLayers.Control.PanZoomBar(),
new OpenLayers.Control.Attribution()],
maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
maxResolution: 156543.0399,
numZoomLevels: 19,
units: ‘m’,
projection: new OpenLayers.Projection(“EPSG:900913”),
displayProjection: new OpenLayers.Projection(“EPSG:4326”)
} );

        layerTilesAtHome = new OpenLayers.Layer.OSM.Osmarender("Osmarender");			
         map.div.oncontextmenu = function noContextMenu(e) {
         if (OpenLayers.Event.isRightClick(e)){
             alert("Right button click"); // Add the right click menu here
    return false; //cancel the right click of brower
        var lonLat = new OpenLayers.LonLat(lon, lat).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject());
        map.setCenter (lonLat, zoom);				

thank you for the solution…