JasonSanford / leaflet-vector-layers

A little help to viewing ArcGIS Server, Geocommons, Arc2Earth, CartoDB, GIS Cloud, etc. vector data in a Leaflet map
http://jasonsanford.github.io/leaflet-vector-layers
BSD 2-Clause "Simplified" License
216 stars 61 forks source link

Add custom clickEvent function #39

Closed bmcbride closed 11 years ago

bmcbride commented 11 years ago

Usage:

clickEvent: function (feature, event) {
    console.log(feature.properties.street_add);
}

Closes #11?

sentenza commented 11 years ago

Could you please explain how to use a console.log() or other functions fired by clickEvent on a lvector object?

bmcbride commented 11 years ago

@sentenza the clickEvent function allows you to do something other than open the standard popup when clicking on a feature. You could use it to open a custom modal window, open a web page, alert the user, anything you can dream up. The consol.log() example above simply logs the Street Address (from the street_add geojson property) to the browser's console. If you are not familiar with using the console, you could change it to alert(feature.properties.street_add); and that would pop up a standard alert box when you clicked on the feature.

sentenza commented 11 years ago

Thank you @bmcbride. I found the solutions one hour ago reading Layer.js. I think it could be documented. I make it works with

clickEvent: function(feature, event){}

on a lvector object.