jekyll-leaflet-mze 0.4.3 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/jekyll-leaflet-mze/leaflet-map.js +75 -39
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: afa2b7ee40ab71b16e0baced796b0051d52aeddc6b4ede477f147e0190cccd8e
|
4
|
+
data.tar.gz: 196b270b1ce18a235888b811caaa640071fd6e4cf3aad9e46caec7e8c48fef5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3bf5b9151551c90c1493adda122a27a6a5682def7920f6ec9663185fcf97f95ee2a38053b60f57195ec0346cd504ad73afb4f84308532b8b9e660e44fb50a82
|
7
|
+
data.tar.gz: 455a074c8ef9422391fbe99e26b2486f3544f0af0cbbad766c89337294f25ca9803babd57cae0acbe53b92396ef59c6cd710553600ffb9785592bec2e7174f65
|
@@ -21,8 +21,6 @@
|
|
21
21
|
document.head.appendChild(defaultMapCssEl);
|
22
22
|
|
23
23
|
var newWindowImgSrcBase64 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAB3RJTUUH4wUVFzAHq2j99AAAAV9JREFUSMdjYKAxYCRHk5ubG9+1a9fm/v//H6cadnb2G/fu3atlIceC379/c3z9+jUEn5q/f/8eYWBgYECxQE5OroqA2Y8ePXq0hJWV9Qc3N/caZB8wMjJKff361QpvEAkKCv4nYMGh9+/f26MLamhoyLx9+3b/nz9/VJCC6MiLFy9sWXCE3xlGRsZvWKQu4DOciYnpCzc396HPnz97weRxWRD/8OHDa4TiAt1wfn5+z79//zoxMDDALWAiN/lhM/zevXtH0NUx0dJwsiwgxXCccUCJ4dzc3DP+//+/gZ2d/duLFy9Is+Djx4+rCbn82rVrrxgYGF6RFUR8fHyZbGxsD7AZLiEhUSAiIrJSUlIyjOw4uHnz5gVHR0d1bC7/8+eP5d+/f8P+/PmjS1Ekr1ix4hcp6ploXVwPfQuwJlMmJiYBLS0tIVIMev36NRvRFnz48OHohw8fhkYQjQKCAAChiL6Pj/LM2QAAAABJRU5ErkJggg==";
|
24
|
-
var iconUrl = "/assets/images/music-map/music-icon.png"
|
25
|
-
var iconSizePixels = [48, 48]
|
26
24
|
|
27
25
|
// Actual mapping section; Specify a function to be called later that
|
28
26
|
// assembles the correct JS components based on what the user specified in the
|
@@ -47,6 +45,23 @@
|
|
47
45
|
}
|
48
46
|
}
|
49
47
|
|
48
|
+
function _getIcon() {
|
49
|
+
// NOTE: retrieved from server, not present in the resources of this plugin
|
50
|
+
var defaultIconSize = [48,48];
|
51
|
+
if("iconPath" in tagInputArg) {
|
52
|
+
var iconSizePixels = defaultIconSize;
|
53
|
+
if("iconSize" in tagInputArg) {
|
54
|
+
iconSizePixels = tagInputArg.iconSize;
|
55
|
+
}
|
56
|
+
return L.icon({
|
57
|
+
iconUrl: tagInputArg.iconPath,
|
58
|
+
iconSize: iconSizePixels
|
59
|
+
});
|
60
|
+
} else {
|
61
|
+
return null;
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
50
65
|
function _getProviderBasemap(){
|
51
66
|
var defaultProviderBasemap = "OpenStreetMap.Mapnik";
|
52
67
|
if("providerBasemap" in tagInputArg){
|
@@ -56,34 +71,57 @@
|
|
56
71
|
}
|
57
72
|
}
|
58
73
|
|
59
|
-
|
60
|
-
function _addMarkerToMap(leafletItem, map, markersLayer){
|
61
|
-
var m = leafletItem.value;
|
62
|
-
var musicIcon = L.icon({
|
63
|
-
iconUrl: iconUrl,
|
64
|
-
iconSize: iconSizePixels
|
65
|
-
});
|
66
|
-
var marker = L.marker(
|
67
|
-
[m.latitude, m.longitude],
|
68
|
-
{icon: musicIcon, title: m.city + ":" + m.popupContent}
|
69
|
-
);
|
70
|
-
markersLayer.addLayer(marker);
|
71
|
-
|
74
|
+
function _mapMarkerPopup(leafletItem) {
|
72
75
|
var potentialPopup = "";
|
73
|
-
if('
|
74
|
-
|
75
|
-
|
76
|
+
if('city' in leafletItem) {
|
77
|
+
potentialPopup += `<b>${leafletItem.city}</b>`;
|
78
|
+
}
|
79
|
+
if('popupContent' in leafletItem){
|
80
|
+
if(leafletItem.popupContent.length == 1) {
|
81
|
+
potentialPopup += '<br/>';
|
82
|
+
potentialPopup += leafletItem.popupContent[0];
|
83
|
+
} else {
|
84
|
+
potentialPopup += '<ul>';
|
85
|
+
leafletItem.popupContent.forEach(item => {
|
76
86
|
potentialPopup += '<li>'
|
77
87
|
potentialPopup += item.trim();
|
78
88
|
potentialPopup += '</li>';
|
79
89
|
});
|
80
90
|
potentialPopup += '</ul>';
|
91
|
+
}
|
81
92
|
}
|
82
|
-
if('href' in
|
83
|
-
potentialPopup += '<a href="' +
|
93
|
+
if('href' in leafletItem){
|
94
|
+
potentialPopup += '<a href="' + leafletItem.href + '">' +
|
84
95
|
'<img src="' + newWindowImgSrcBase64 + '"></img></a>';}
|
85
|
-
|
86
|
-
|
96
|
+
return potentialPopup;
|
97
|
+
}
|
98
|
+
|
99
|
+
function _markerProps(icon, leafletValue) {
|
100
|
+
var props = {};
|
101
|
+
if(icon) {
|
102
|
+
props.icon = icon;
|
103
|
+
}
|
104
|
+
props.title = "";
|
105
|
+
if('city' in leafletValue) {
|
106
|
+
props.title += leafletValue.city;
|
107
|
+
}
|
108
|
+
if('popupContent' in leafletValue) {
|
109
|
+
props.title += leafletValue.popupContent;
|
110
|
+
}
|
111
|
+
return props;
|
112
|
+
}
|
113
|
+
|
114
|
+
|
115
|
+
function _mapMarker(leafletItem, map){
|
116
|
+
var m = leafletItem.value;
|
117
|
+
var icon = _getIcon();
|
118
|
+
var markerProps = _markerProps(icon, m);
|
119
|
+
var marker = L.marker([m.latitude, m.longitude], markerProps);
|
120
|
+
var popup = _mapMarkerPopup(m);
|
121
|
+
|
122
|
+
if(popup){
|
123
|
+
marker.bindPopup(popup);
|
124
|
+
}
|
87
125
|
if(!('center' in tagInputArg)){
|
88
126
|
// If the user didn't specify a center, infer from marker
|
89
127
|
map.panTo(new L.LatLng(m.latitude, m.longitude));
|
@@ -95,6 +133,7 @@
|
|
95
133
|
opacity: '0.95'
|
96
134
|
})
|
97
135
|
}
|
136
|
+
return marker;
|
98
137
|
}
|
99
138
|
|
100
139
|
function _onEachFeature(feature, layer){
|
@@ -152,7 +191,8 @@
|
|
152
191
|
function _processLeafletItem(leafletItem, map, markersLayer){
|
153
192
|
switch(leafletItem.type){
|
154
193
|
case "LeafletMarker":
|
155
|
-
|
194
|
+
var marker = _mapMarker(leafletItem, map);
|
195
|
+
markersLayer.addLayer(marker);
|
156
196
|
break;
|
157
197
|
case "LeafletGeoJSON":
|
158
198
|
_addGeoJSONToMap(leafletItem, map);
|
@@ -218,6 +258,16 @@
|
|
218
258
|
}
|
219
259
|
}
|
220
260
|
|
261
|
+
function _addCssStylesheetToDom(elementId, stylesheetPath) {
|
262
|
+
var leafletCssEl = document.createElement("link");
|
263
|
+
leafletCssEl.id = elementId;
|
264
|
+
leafletCssEl.rel = "stylesheet";
|
265
|
+
leafletCssEl.href = stylesheetPath;
|
266
|
+
if(!document.getElementById(leafletCssEl.id)){
|
267
|
+
document.head.appendChild(leafletCssEl);
|
268
|
+
}
|
269
|
+
}
|
270
|
+
|
221
271
|
var leafletCssId = "leaflet-css-head";
|
222
272
|
var leafletJsId = "leaflet-js-head";
|
223
273
|
var leafletSearchCssId = "leaflet-search-css-head";
|
@@ -225,22 +275,8 @@
|
|
225
275
|
var esriLeafletJsId = "esri-leaflet-js-head";
|
226
276
|
var leafletProvidersJsId = "leaflet-providers-js-head";
|
227
277
|
|
228
|
-
|
229
|
-
|
230
|
-
leafletCssEl.id = leafletCssId;
|
231
|
-
leafletCssEl.rel = "stylesheet";
|
232
|
-
leafletCssEl.href = leafletCdn + "leaflet.css";
|
233
|
-
if(!document.getElementById(leafletCssEl.id)){
|
234
|
-
document.head.appendChild(leafletCssEl);
|
235
|
-
}
|
236
|
-
|
237
|
-
var leafletSearchCssEl = document.createElement("link");
|
238
|
-
leafletSearchCssEl.id = leafletSearchCssId;
|
239
|
-
leafletSearchCssEl.rel = "stylesheet";
|
240
|
-
leafletSearchCssEl.href = leafletSearchCdn + "leaflet-search.min.css";
|
241
|
-
if(!document.getElementById(leafletSearchCssEl.id)){
|
242
|
-
document.head.appendChild(leafletSearchCssEl);
|
243
|
-
}
|
278
|
+
_addCssStylesheetToDom(leafletCssId, leafletCdn + "leaflet.css");
|
279
|
+
_addCssStylesheetToDom(leafletSearchCssId, leafletSearchCdn + "leaflet-search.min.css");
|
244
280
|
|
245
281
|
function addToHeadIfNotLoaded(el) {
|
246
282
|
//Add the el to the head if it doesn't exist already. If it does,
|