forked from informatici/survethi-monitoring-tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
map.html
111 lines (90 loc) · 4.08 KB
/
map.html
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<!DOCTYPE html>
<html>
<head>
<title>PHP Mysql REST API CRUD</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" />
<link rel="stylesheet" href="https://unpkg.com/leaflet-routing-machine@latest/dist/leaflet-routing-machine.css" />
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<script src="https://unpkg.com/leaflet-routing-machine@latest/dist/leaflet-routing-machine.js"></script>
<script src="https://unpkg.com/[email protected]/dist/leaflet.markercluster.js"></script>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/MarkerCluster.css" />
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/MarkerCluster.Default.css" />
<script src="./static/js/leaflet-heat.js"></script>
<!-- <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css" /> -->
<!-- <link rel="stylesheet" href="../dist/MarkerCluster.css" />
<link rel="stylesheet" href="../dist/MarkerCluster.Default.css" />
<script src="../dist/leaflet.markercluster-src.js"></script>
<link rel="stylesheet" type="text/css" href="../css/style.css">
<link rel="stylesheet" type="text/css" href="../css/style2.css"> -->
</head>
<body>
<div id="mapid"
style="height: 500px; position: relative; overflow: hidden"
class="leaflet-container leaflet-touch leaflet-retina leaflet-fade-anim leaflet-grab leaflet-touch-drag leaflet-touch-zoom"
tabindex="0">
<div class="leaflet-pane leaflet-map-pane"
style="transform: translate3d(0px, 0px, 0px);">
</div>
</div>
<script type="text/javascript">
var response;
$(document).ready(function(response){
fetch_data();
function fetch_data(){
$.ajax({
url:"http://127.0.0.1:5000/test_group",
success:function(data,status,xhr)
{
show_markers(data);
}
})
}
})
function show_markers(response) {
var markersGroup1 = L.markerClusterGroup();
var markerArray = [];
//var markersGroup2 = L.markerClusterGroup();
// var markersGroup3 = L.markerClusterGroup();
response.forEach(show_marker);
mymap.addLayer(markersGroup1);
//mymap.addLayer(markersGroup2);
// mymap.addLayer(markersGroup3);
var heat = L.heatLayer(markerArray, {radius: 50}).addTo(mymap);
function show_marker(item, index) {
if (item.LOC_LAT) {
markerArray.push([item.LOC_LAT, item.LOC_LONG, 0.2]);
var description = getMarkerDescription(item);
if (item.OPD_DIS_ID_A == "1567")
markersGroup1.addLayer(
new L.marker([parseFloat(item.LOC_LAT), parseFloat(item.LOC_LONG)],
{icon: L.icon({iconUrl: 'static/img/blue_icon.png', iconSize: [32, 32]})}).bindPopup(description));
else if (item.OPD_DIS_ID_A == "782")
markersGroup1.addLayer(
new L.marker([parseFloat(item.LOC_LAT), parseFloat(item.LOC_LONG)],
{icon: L.icon({iconUrl: 'static/img/pink_icon.png', iconSize: [32, 32]})}).bindPopup(description));
/* else
markersGroup3.addLayer(
new L.marker([parseFloat(item.LOC_LAT), parseFloat(item.LOC_LONG)],
{icon: L.icon({iconUrl: 'static/img/grey_icon.png', iconSize: [32, 32]})}).bindPopup(description)); */
}
}
function getMarkerDescription(item) {
if (item.COUNT)
return item.COUNT + "<br>" + item.LOC_CITY + "<br>" + item.LOC_ADDRESS + "<br>" + item.DIS_DESC
else
return item.LOC_CITY + "<br>" + item.LOC_ADDRESS + "<br>" + item.DIS_DESC
}
}
var mymap = L.map('mapid').setView([8.52944, 37.95472], 11);
L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', {
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
maxZoom: 18,
id: 'mapbox.streets',
accessToken: 'pk.eyJ1Ijoibmljb3B1bnppIiwiYSI6ImNqamU5aHhrZzRqZWMzcW80ZjE3dWNwZnoifQ.6X2-0SFwNzx_mjXrk9cysw'
}).addTo(mymap);
</script>
</body>
</html>