Add interactive points demo to the readme

This commit is contained in:
Iván Sánchez Ortega
2016-11-07 16:54:53 +01:00
parent 84845903f5
commit 3ae6ff29b9
3 changed files with 7 additions and 3 deletions

View File

@ -6,3 +6,5 @@ gobblefile.js
aux
.gobble
.gobble-build
yarn.lock
demo

View File

@ -20,6 +20,8 @@ With sliced TopoJSON: http://leaflet.github.io/Leaflet.VectorGrid/dist/demo/demo
With protobuf `VectorTile`s: http://leaflet.github.io/Leaflet.VectorGrid/dist/demo/demo-vectortiles.html
With clickable points and lines (from protobuf tiles): http://leaflet.github.io/Leaflet.VectorGrid/dist/demo/demo-points.html
## Using

View File

@ -70,7 +70,7 @@
road_label: [],
housenum_label: [],
},
interactive: true,
interactive: true, // Make sure that this VectorGrid fires mouse/pointer events
getFeatureId: function(f) {
return f.properties.osm_id;
}
@ -86,7 +86,7 @@
highlight = null;
};
var pbfLayer = L.vectorGrid.protobuf(url, vectorTileOptions)
.on('click', function(e) {
.on('click', function(e) { // The .on method attaches an event handler
L.popup()
.setContent(e.layer.properties.name || e.layer.properties.type)
.setLatLng(e.latlng)
@ -113,4 +113,4 @@
map.setView([40.9994639, -74.163208], 15);
</script>
</body>
</html>
</html>