scripts.js 4.71 KB
Newer Older
Manggar Mahardhika's avatar
Manggar Mahardhika committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
// $(window).on("load", function() {
//     loaderPage(true);
// });

$(document).ready(function() {
    // loaderPage(true);
    const $valueSpan = $('.valueSpan');
    const $value_address = $('#slider-address');
    const $value_point = $('#slider-point');
    $valueSpan.html($value_address.val());
    $value_address.on('input change', () => {
        $valueSpan.html($value_address.val());
    });

    $valueSpan.html($value_point.val());
    $value_point.on('input change', () => {
        $valueSpan.html($value_point.val());
    });

});

var lat, lng, latlng;
var container = $(".leaflet-control-layers")[0];
var markerClusters = new L.MarkerClusterGroup({
    spiderfyOnMaxZoom: true,
    showCoverageOnHover: false,
    zoomToBoundsOnClick: true,
    disableClusteringAtZoom: 16
});
var marker = {};

$(window).resize(function() {
    sizeLayerControl();
});


if (!("ontouchstart" in window)) {
    $(document).on("mouseover", ".feature-row", function(e) {
        highlight.clearLayers().addLayer(L.circleMarker([$(this).attr("lat"), $(this).attr("lng")], highlightStyle));
    });
}

$(document).on("mouseout", ".feature-row", clearHighlight);

$("#about-btn").click(function() {
    $("#aboutModal").modal("show");
    $(".navbar-collapse.in").collapse("hide");
    return false;
});

$("#login-btn").click(function() {
    $("#loginModal").modal("show");
    $(".navbar-collapse.in").collapse("hide");
    return false;
});

$("#sid").click(function() {
    $("#sid").css('display', 'none');
    $("#sidebar").css('display', 'block');
    $("#offsid").css('display', 'block');

});

$("#offsid").click(function() {
    $("#offsid").css('display', 'none');
    $("#sidebar").css('display', 'none');
    $("#sid").css('display', 'block');
});

$("#button_hide").click(function() {
    $("#thisFooter").css('display', 'none');
    $("#button_unhide").css('display', 'block');

})

$("#button_unhide").click(function() {
    $("#thisFooter").css('display', 'block');
    $("#button_unhide").css('display', 'none');
Muhamad's avatar
Muhamad committed
79 80 81
})

$("#button_hide_panel").click(function() {
prabaswara's avatar
prabaswara committed
82
    $("#panel-samping").toggleClass("move");
Muhamad's avatar
Muhamad committed
83

prabaswara's avatar
prabaswara committed
84
    // $("#panel-samping").css('display', 'none');
Muhamad's avatar
Muhamad committed
85 86
    $("#button_unhide_panel").css('display', 'block');
    $("#button_hide_panel").css('display', 'none');
prabaswara's avatar
prabaswara committed
87 88
    // $("#thisFooter").css('left', '0px');
    // $('#legenda').css('left', '0px');
Muhamad's avatar
Muhamad committed
89

Muhamad's avatar
Muhamad committed
90 91

})
Manggar Mahardhika's avatar
Manggar Mahardhika committed
92

93 94 95 96 97 98 99 100 101
$("#button_keterangan").click(function() {
    $(".pace-done").toggleClass("sidebar-move")
    $("#panel-samping").toggleClass("move");
    $(".mymodal").toggleClass("input_perbaikan")
    $("#button_unhide_panel").toggleClass("move-btn");
})



Muhamad's avatar
Muhamad committed
102
$("#button_unhide_panel").click(function() {
Muhamad's avatar
Muhamad committed
103
    $(".pace-done").toggleClass("sidebar-move")
prabaswara's avatar
prabaswara committed
104
    $("#panel-samping").toggleClass("move");
Muhamad's avatar
Muhamad committed
105
    $(".mymodal").toggleClass("input_perbaikan")
prabaswara's avatar
prabaswara committed
106
    $(this).toggleClass("move-btn");
107
})
Muhamad's avatar
Muhamad committed
108

109 110 111 112 113 114 115 116 117

$("#manage_perbaikan").click(function() {
    $(".pace-done").toggleClass("sidebar-move");
    $("#panel-samping").toggleClass("move");
    $(".mymodal").toggleClass("input_perbaikan");
    $("#button_unhide_panel").toggleClass("move-btn");

    $("#perbaikan-dashboard").toggleClass("perbaikan-dashboard");

Manggar Mahardhika's avatar
Manggar Mahardhika committed
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
})


function sizeLayerControl() {
    $(".leaflet-control-layers").css("max-height", $("#map").height() - 50);
}

function clearHighlight() {
    highlight.clearLayers();
}

var highlight = L.geoJson(null);
var highlightStyle = {
    stroke: false,
    fillColor: "#00FFFF",
    fillOpacity: 0.7,
    radius: 10
};

map.on("click", function(e) {
    highlight.clearLayers();
});

function updateAttribution(e) {
    $.each(map._layers, function(index, layer) {
        if (layer.getAttribution) {
            $("#attribution").html((layer.getAttribution()));
        }
    });
}
map.on("layeradd", updateAttribution);
map.on("layerremove", updateAttribution);

var attributionControl = L.control({
    position: "topleft"
});

attributionControl.onAdd = function(map) {
    var div = L.DomUtil.create("div", "leaflet-control-attribution");
    return div;
};
map.addControl(attributionControl);

var zoomControl = L.control.zoom({
Muhamad's avatar
Muhamad committed
162
    position: "bottomright"
Manggar Mahardhika's avatar
Manggar Mahardhika committed
163 164 165
}).addTo(map);

var locateControl = L.control.locate({
Muhamad's avatar
Muhamad committed
166
    position: "bottomright",
Manggar Mahardhika's avatar
Manggar Mahardhika committed
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
    drawCircle: false,
    follow: true,
    setView: true,
    keepCurrentZoomLevel: false,
    markerStyle: {
        weight: 1,
        opacity: 0.8,
        fillOpacity: 0.8
    },
    circleStyle: {
        weight: 1,
        clickable: false
    },
    icon: "fa fa-map-marker",
    metric: false,
    strings: {
        title: "My location",
    },
    locateOptions: {}
}).addTo(map);

if (document.body.clientWidth <= 767) {
    var isCollapsed = true;
} else {
    var isCollapsed = false;
}

$("#featureModal").on("hidden.bs.modal", function(e) {
    $(document).on("mouseout", ".feature-row", clearHighlight);
});