Leaflet: Pass parameter on Click function

Created on 12 Dec 2013  Â·  2Comments  Â·  Source: Leaflet/Leaflet

can I pass multiple parameter on click event function ? If yes then how to pass parameter .. when I pass parameter callback error are displaying.

Example :
var ID = 2;
MapClick.on('click', onMapClick(ID));

function onMapClick(ID) {
alert(ID);
}

Most helpful comment

This is a JavaScript question, not a Leaflet bug — please ask similar questions on the forum instead.

One way is to do MapClick.on('click', L.bind(onMapClick, null, ID)).

All 2 comments

This is a JavaScript question, not a Leaflet bug — please ask similar questions on the forum instead.

One way is to do MapClick.on('click', L.bind(onMapClick, null, ID)).

Hi Vladimir ,

It's working, Thanks for help.

Regards,
Hemant

On Thu, Dec 12, 2013 at 6:46 PM, Vladimir Agafonkin <
[email protected]> wrote:

Closed #2286 https://github.com/Leaflet/Leaflet/issues/2286.

—
Reply to this email directly or view it on GitHubhttps://github.com/Leaflet/Leaflet/issues/2286
.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

timwis picture timwis  Â·  3Comments

gdbd picture gdbd  Â·  3Comments

prbaron picture prbaron  Â·  3Comments

arminghm picture arminghm  Â·  3Comments

onethread picture onethread  Â·  3Comments