-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
98 lines (59 loc) · 1.93 KB
/
script.js
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
var map = L.map('map').setView([13.0864,80.2644], 14);
var theMarker;
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
minZoom: 7,
maxZoom: 18,
attribution: ' © deliGenie contributors | DO NOT USE FOR ANY COMMERCIAL PURPOSES | Disclaimer | © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(map);
/* Adding a custom default location for test purposes. Should be removed when used on live websites */
var myIcon = L.icon({
iconUrl: 'images/restaurant.png',
iconSize:[30,40]
});
var marker = new L.Marker([13.0864,80.2644], 14);
marker.addTo(map);
function onEachFeature(feature, layer) {
layer.on('click', function (e)
{
createCircle(feature);
if(!layer.getPopup()){
layer.bindPopup(PopupContent(feature)).openPopup();}
}
)}
$.getJSON('https://raw.githubusercontent.com/webVerts/vC/main/data.json', function (geojson) {
const hotelLayer = L.geoJson(geojson, {
onEachFeature: onEachFeature,
pointToLayer: function(feature, latlng) {
return L.marker(latlng, {icon: myIcon});
}
},).addTo(map);
});
function PopupContent(outlet){
var name = outlet.properties.name;
var diet = outlet.properties.diet;
var cuisine = outlet.properties.cuisine;
var KM = (outlet.properties.radius)/1000;
return `<div>
<h4> ${name} </h1>
<p> Diet: ${diet} </p>
<p> Cuisine: ${cuisine} </p>
<p> ${KM} KM Free delivery </p>
<a href ="#"> Menu </a><br><br>
<a href ="#"> Contact </a>
</div> `;
}
function createCircle(outlet){
op(outlet);
function op(outlet)
{
var radius = outlet.properties.radius;
var lat = outlet.geometry.coordinates[1];
var lng = outlet.geometry.coordinates[0];
if (theMarker != undefined) {
map.removeLayer(theMarker);
};
theMarker = L.circle([lat,lng], {radius: radius,color: '#c6993a', fillOpacity:0.00
}).addTo(map);
return 0;
}
}