diff --git a/debug/vector/geojson.html b/debug/vector/geojson.html
index fb7d7af9..3c615f4e 100644
--- a/debug/vector/geojson.html
+++ b/debug/vector/geojson.html
@@ -10,12 +10,11 @@
@@ -38,9 +37,6 @@
}).addTo(map);
- L.control.scale().addTo(map);
-
-
var info = L.Util.extend(L.control(), {
onAdd: function (map) {
@@ -50,10 +46,10 @@
},
setFeature: function (feature) {
- this._div.innerHTML = feature ?
+ this._div.innerHTML = (feature ?
'' + feature.properties.name + '' +
- '
' + feature.properties.density + ' /mi2'
- : 'Hover over a state';
+ ': ' + feature.properties.density + ' /mi2'
+ : 'Hover over a state');
}
});
@@ -77,24 +73,32 @@
}
function highlightFeature(e) {
- var style = L.Util.extend({}, defaultStyle, {
- weight: 3,
- color: '#555',
+ var layer = e.target;
+
+ layer.bringToFront().setStyle({
+ weight: 5,
+ color: '#666',
dashArray: ''
});
- e.target.setStyle(style).bringToFront();
+
info.setFeature(e.target.feature);
}
function resetHighlight(e) {
e.target.setStyle(defaultStyle);
+
info.setFeature(null);
}
+ function zoomToFeature(e) {
+ map.fitBounds(e.target.getBounds());
+ }
+
function onEachFeature(feature, layer) {
layer.feature = feature;
layer.on('mouseover', highlightFeature);
layer.on('mouseout', resetHighlight);
+ layer.on('click', zoomToFeature);
}
var geojson = L.geoJson(statesData, {