forked from pyvec/python.cz
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaps.js
More file actions
42 lines (34 loc) · 1.16 KB
/
Copy pathmaps.js
File metadata and controls
42 lines (34 loc) · 1.16 KB
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
var layer = L.tileLayer('https://a.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png', {
maxZoom: 18,
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
});
var icon = L.icon({
iconUrl: '/static/images/icon.png',
iconSize: [16, 16],
shadowSize: [0, 0],
iconAnchor: [8, 8],
popupAnchor: [0, 0]
});
$(function() {
var element = $('#map');
var zoom = element.attr('data-zoom') || 7;
var lat = element.attr('data-lat') || 49.8;
var lng = element.attr('data-lng') || 15.55;
var map = L.map('map', {'scrollWheelZoom': false})
.setView([lat, lng], zoom)
.addLayer(layer);
var dataUrl = element.attr('data-src');
$.getJSON(dataUrl, function(data) {
L.geoJson(data, {
pointToLayer: function (feature, coordinates) {
return L.marker(coordinates, {icon: icon});
},
onEachFeature: function (feature, marker) {
if (feature.properties) {
text = '<h3>' + feature.properties.name + '<h3>'
marker.bindPopup(text);
}
}
}).addTo(map);
});
});