WMS GetFeatureInfo in OpenLayers on right click

Assuming that one already has a WMSGetFeatureInfo on the map then its quite simple:

  • Add new class
  • Use new class

New class

   // A control class for capturing click events...

   OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
       defaultHandlerOptions: {
           'single'true,
           'double'true,
           'pixelTolerance': 0,
           'stopSingle'false,
           'stopDouble'false
       },
       handleRightClicks: true,
       initialize: function (options) {
           this.handlerOptions = OpenLayers.Util.extend(
             {}, this.defaultHandlerOptions
           );
           OpenLayers.Control.prototype.initialize.apply(
             this, arguments
            );
           this.handler = new OpenLayers.Handler.Click(
             thisthis.eventMethods, this.handlerOptions
           );
       },
       CLASS_NAME: "OpenLayers.Control.Click" 
   });

 

Use it

    // Add an instance of the Click control that listens to various click events:

    var oClick = new OpenLayers.Control.Click({ eventMethods: {
        'rightclick'function (e) {
            //the infotool has already been added to the map so lets use it!  No need to fuff about and do the request ourselves is there?
            infoTool.request(e.xy);
        }
    }
    });
    map.addControl(oClick);
    oClick.activate();
 

Comments

abed

re: WMS GetFeatureInfo in OpenLayers on right click

20 March 2017

hello,

Can you give me the link of the article where you are defined the variable infoTool please ?

Thanks

Find out more