-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeojson-map.admin.js.erb
38 lines (30 loc) · 1.05 KB
/
geojson-map.admin.js.erb
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
/**
* Map Location
*/
var osmUrl = "https://osm.cdsh.dev/hot/{z}/{x}/{y}.png";
const nominatimUrl = "https://nominatim.cdsh.dev";
// set map
var map = L.map("map", {
minZoom: 10,
maxZoom: 15,
gestureHandling: true,
}).setView([52.22977, 21.01178], 11);
const TOOLTIP_ZOOM_THRESHOLD = 15;
$("#map").removeAttr("tabIndex");
L.tileLayer(osmUrl, {
attribution:
'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
}).addTo(map);
L.Marker.prototype.options.icon = L.icon({
iconUrl: <%= "'#{asset_path("locations-map/images/marker-icon.png")}'" %>,
iconRetinaUrl: <%= "'#{asset_path("locations-map/images/marker-icon-2x.png")}'" %>,
shadowUrl: <%= "'#{asset_path("locations-map/images/marker-shadow.png")}'" %>,
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
tooltipAnchor: [16, -28],
shadowSize: [41, 41]
});
const layer = L.geoJSON(JSON.parse($("input[name=locations]").val()));
layer.addTo(map);
map.fitBounds(layer.getBounds(), {"animate": false});