var marker141Layers = null; var marker141List = []; var marker141LayersWithoutCluster = null; var allpointdatashow = null; var portasadofpp = []; function showLoaderScreen() { $(".divloader").css("display", "flex").hide().fadeIn(); } function hideLoaderScreen() { $(".divloader").fadeOut(); } var rediconfix = L.divIcon({ className: "custom-div-icon", html: "", iconSize: [30, 42], // iconAnchor: [15, 42] }); const API_ENDPOINT = "https://141.ir/api"; const MAP_ENDPOINT = "https://rmsmap.rmto.ir"; const MAP_MIN_ZOOM = 6; const MAP_MAX_ZOOM = 15; var bounds = [ [42.9130026312, 75.6166317076], [20.5782370061, 30.5092252948], ]; var map = L.map("map", { maxBounds: bounds, minZoom: MAP_MIN_ZOOM, zoomControl: false, }).setView([35.5468992, 51.7300532], 7); L.tileLayer(MAP_ENDPOINT + "/141map/{z}/{x}/{y}.png", {}).addTo(map); L.PrintPreview().addTo(map); var greenIcon = L.divIcon({ className: "custom-div-icon", html: "", iconSize: [30, 42], // iconAnchor: [15, 42] }); var redIcon = L.divIcon({ className: "custom-div-icon", html: "", iconSize: [30, 42], // iconAnchor: [15, 42] }); function showLoaderScreen() { $(".divloader").css("display", "flex").hide().fadeIn(); } function hideLoaderScreen() { $(".divloader").fadeOut(); } function remove141Layer() { if (marker141Layers != null) { marker141List = []; map.removeLayer(marker141Layers); $(".left-menu-141 > .item-menu-141.item-141-active").removeClass( "item-141-active" ); } if (marker141LayersWithoutCluster != null) { map.removeLayer(marker141LayersWithoutCluster); } } $("#firstradio").change( function () { if ($(this).is(':checked')) { showallpoints() // append goes here } }); $("#secondradio").change( function () { if ($(this).is(':checked')) { showbelghove() // append goes here } }); $("#thirdradio").change( function () { if ($(this).is(':checked')) { showaccidentpoints() // append goes here } }); $(".filterTitle").on("click", function () { if ($(this).parent().children(".filterGroup").css("display") == "none") { $(this).parent().children(".filterGroup").show(1000); } else { $(this).parent().children(".filterGroup").hide(1000); } }) function showallpoints() { if (marker141Layers != null) { marker141List = []; map.removeLayer(marker141Layers); } if (marker141LayersWithoutCluster != null) { map.removeLayer(marker141LayersWithoutCluster); } let markerG = []; showLoaderScreen(); $.ajax({ url: "https://rms.rmto.ir/webapi/danger-point/getlist", type: "GET", success: function (result) { console.log(result); allpointdatashow = result.data; console.log("allpointdatashow", allpointdatashow) for (var i = 0; i < allpointdatashow.length; i++) { try { let marker = null; console.log("hghg", allpointdatashow[i].lat_lng) marker = L.marker( allpointdatashow[i].lat_lng, { color: "#FF0000", stroke: false, radius: 2, fillOpacity: 1, } ) markerG.push(marker); } catch (e) { console.log(e); } } marker141Layers = L.layerGroup(markerG); map.addLayer(marker141Layers); hideLoaderScreen(); }, error: function (error) { //console.log(error); }, }); } function showbelghove() { remove141Layer(); // showLoaderScreen(); showLoaderScreen() if (marker141Layers != null) { marker141List = []; map.removeLayer(marker141Layers); } if (marker141LayersWithoutCluster != null) { map.removeLayer(marker141LayersWithoutCluster); } $.ajax({ url: "https://rms.rmto.ir/api/danger-points-result", type: "GET", success: function (result) { console.log(result); let roadAccidentPoints = result.data; hideLoaderScreen(); //console.log(roadAccidentPoints); let markerG = []; let setIcon = null; for (let i = 0; i < roadAccidentPoints.length; i++) { try { let marker = null; marker = L.circleMarker( [roadAccidentPoints[i].j, roadAccidentPoints[i].h], { color: "#FF0000", stroke: false, radius: 2, fillOpacity: 1, } ) markerG.push(marker); } catch (e) { console.log(e); } } marker141Layers = L.layerGroup(markerG); map.addLayer(marker141Layers); }, error: function (error) { //console.log(error); }, }); } function showaccidentpoints() { remove141Layer(); // showLoaderScreen(); showLoaderScreen() if (marker141Layers != null) { marker141List = []; map.removeLayer(marker141Layers); } if (marker141LayersWithoutCluster != null) { map.removeLayer(marker141LayersWithoutCluster); } $.ajax({ url: "https://rms.rmto.ir/api/danger-points-result", type: "GET", success: function (result) { console.log(result); let roadAccidentPoints = result.data; hideLoaderScreen(); //console.log(roadAccidentPoints); for (let i = 0; i < roadAccidentPoints.length; i++) { if (roadAccidentPoints[i].pp >= 0.95) { portasadofpp.push(roadAccidentPoints[i]) } } console.log("portasadofpp", portasadofpp) let markerG = []; let setIcon = null; for (let i = 0; i < portasadofpp.length; i++) { try { let marker = null; marker = L.circleMarker( [portasadofpp[i].j, portasadofpp[i].h], { color: "#FF0000", stroke: false, radius: 2, fillOpacity: 1, } ) markerG.push(marker); } catch (e) { console.log(e); } } marker141Layers = L.layerGroup(markerG); map.addLayer(marker141Layers); }, error: function (error) { //console.log(error); }, }); }