1 $(document).ready(function () {
2 var changesets = [], rects = {};
4 var map = L.map("changeset_list_map", {
5 attributionControl: false,
7 }).addLayer(new L.OSM.Mapnik());
12 var group = L.featureGroup().addTo(map);
14 $("[data-changeset]").each(function () {
15 var changeset = $(this).data('changeset');
17 changeset.bounds = L.latLngBounds([changeset.bbox.minlat, changeset.bbox.minlon],
18 [changeset.bbox.maxlat, changeset.bbox.maxlon]);
19 changesets.push(changeset);
23 changesets.sort(function (a, b) {
24 return b.bounds.getSize() - a.bounds.getSize();
27 for (var i = 0; i < changesets.length; ++i) {
28 var changeset = changesets[i],
29 rect = L.rectangle(changeset.bounds,
30 {weight: 2, color: "#ee9900", fillColor: "#ffff55", fillOpacity: 0});
31 rect.id = changeset.id;
32 rects[changeset.id] = rect;
36 function highlightChangeset(id) {
37 rects[id].setStyle({fillOpacity: 0.5});
38 $("#changeset_" + id).addClass("selected");
41 function unHighlightChangeset(id) {
42 rects[id].setStyle({fillOpacity: 0});
43 $("#changeset_" + id).removeClass("selected");
47 mouseover: function (e) {
48 highlightChangeset(e.layer.id);
50 mouseout: function (e) {
51 unHighlightChangeset(e.layer.id);
55 $("[data-changeset]").on({
56 mouseover: function () {
57 highlightChangeset($(this).data("changeset").id);
59 mouseout: function () {
60 unHighlightChangeset($(this).data("changeset").id);
64 $(window).scroll(function() {
65 if ($(window).scrollTop() > $('.content-heading').outerHeight() + $('#top-bar').outerHeight() ) {
66 $('#changeset_list_map_wrapper').addClass('scrolled');
68 $('#changeset_list_map_wrapper').removeClass('scrolled');
72 var params = OSM.mapParams();
74 map.fitBounds([[params.minlat, params.minlon],
75 [params.maxlat, params.maxlon]]);
77 map.fitBounds(group.getBounds());