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 $("#changeset_list_map").on("resized", function () {
16 var group = L.featureGroup().addTo(map);
18 $("[data-changeset]").each(function () {
19 var changeset = $(this).data('changeset');
21 changeset.bounds = L.latLngBounds([changeset.bbox.minlat, changeset.bbox.minlon],
22 [changeset.bbox.maxlat, changeset.bbox.maxlon]);
23 changesets.push(changeset);
27 changesets.sort(function (a, b) {
28 return b.bounds.getSize() - a.bounds.getSize();
31 for (var i = 0; i < changesets.length; ++i) {
32 var changeset = changesets[i],
33 rect = L.rectangle(changeset.bounds,
34 {weight: 2, color: "#ee9900", fillColor: "#ffff55", fillOpacity: 0});
35 rect.id = changeset.id;
36 rects[changeset.id] = rect;
40 function highlightChangeset(id) {
41 rects[id].setStyle({fillOpacity: 0.5});
42 $("#changeset_" + id).addClass("selected");
45 function unHighlightChangeset(id) {
46 rects[id].setStyle({fillOpacity: 0});
47 $("#changeset_" + id).removeClass("selected");
51 mouseover: function (e) {
52 highlightChangeset(e.layer.id);
54 mouseout: function (e) {
55 unHighlightChangeset(e.layer.id);
59 $("[data-changeset]").on({
60 mouseover: function () {
61 highlightChangeset($(this).data("changeset").id);
63 mouseout: function () {
64 unHighlightChangeset($(this).data("changeset").id);
68 $(window).scroll(function() {
69 if ($(window).scrollTop() > $('.content-heading').outerHeight() + $('#top-bar').outerHeight() ) {
70 $('#changeset_list_map_wrapper').addClass('scrolled');
72 $('#changeset_list_map_wrapper').removeClass('scrolled');
76 var params = OSM.mapParams();
78 map.fitBounds([[params.minlat, params.minlon],
79 [params.maxlat, params.maxlon]]);
81 map.fitBounds(group.getBounds());