1 function initializeChangesets(map) {
2 var changesets = [], rects = {};
4 var group = L.featureGroup().addTo(map);
6 $("[data-changeset]").each(function () {
7 var changeset = $(this).data('changeset');
9 changeset.bounds = L.latLngBounds([changeset.bbox.minlat, changeset.bbox.minlon],
10 [changeset.bbox.maxlat, changeset.bbox.maxlon]);
11 changesets.push(changeset);
15 changesets.sort(function (a, b) {
16 return b.bounds.getSize() - a.bounds.getSize();
19 for (var i = 0; i < changesets.length; ++i) {
20 var changeset = changesets[i],
21 rect = L.rectangle(changeset.bounds,
22 {weight: 2, color: "#ee9900", fillColor: "#ffff55", fillOpacity: 0});
23 rect.id = changeset.id;
24 rects[changeset.id] = rect;
28 function highlightChangeset(id) {
29 rects[id].setStyle({fillOpacity: 0.5});
30 $("#changeset_" + id).addClass("selected");
33 function unHighlightChangeset(id) {
34 rects[id].setStyle({fillOpacity: 0});
35 $("#changeset_" + id).removeClass("selected");
39 mouseover: function (e) {
40 highlightChangeset(e.layer.id);
42 mouseout: function (e) {
43 unHighlightChangeset(e.layer.id);
47 $("[data-changeset]").on({
48 mouseover: function () {
49 highlightChangeset($(this).data("changeset").id);
51 mouseout: function () {
52 unHighlightChangeset($(this).data("changeset").id);