www.webdeveloper.com
Results 1 to 3 of 3

Thread: [OpenLayers] Register map click event

  1. #1
    Join Date
    Oct 2012
    Posts
    2

    [OpenLayers] Register map click event

    Hi,

    I have an OpenLayers.Map() object on which I'd like to register a click event. For that, I do the following:
    Code:
    // This function has to be declared outside map.events.on() in order to be able to unregister the map click.
    var mafnc = function(e){...};   
    
    // Map click event registration 
    map.events.on({
     	click : mafnc 
    });
    
    // Map click event unregistration
    map.events.un({
     	click : mafnc 
    });
    The problem is the following error:
    Code:
    TypeError: d.func.apply is not a function
    If I use, instead, the following code, I get no error. The inconvenient is that unregistration of the map click becomes impossible (?):
    Code:
    map.events.on({
     	click : function(e){...} 
    });
    Do you have any hint about how to use the first code snippet without getting the error?

    Best regards.

  2. #2
    Join Date
    Nov 2006
    Location
    Oakland
    Posts
    500
    Your snippet does not show any variable or function named func. I can only see mafnc.

  3. #3
    Join Date
    Oct 2012
    Posts
    2
    Thanks holyhttp for your response.
    In fact, Firebug says that the error is detected in the OpenLayers.js file (which is the OpenLayers file Library).
    I did not mention that I'm using ExtJS in my application. So the code illustrated above is inside Ext.onReady(function(){...});
    The complete error text is :
    Code:
    TypeError: d.func.apply is not a function
    anonymous()                                                                                                     OpenLayers.js (ligne 62)
    ...]);return function(){var d=c.concat(Array.prototype.slice.apply(arguments,[0]));...    OpenLayers.js (ligne 62)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles