jekyll-leaflet-mze 0.4.3 → 0.4.4
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 +76 -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: 7ea4f3a41cdee4eb9ea02169323a51b1cda5fcf014e1dd6973f41d1e8d51cb59
|
4
|
+
data.tar.gz: 2431d27347eb0a91958e60b40605abdee53abf2aa9e1dad8fb350a0bfc73bb7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd7f667928c83a7a5c8c4082c3e6bd3e82eb5a51f2c08bf955cde2e9eca2549186f5151051b1372545234854d99cfe6c6b98af74bcd0071ab3e3972677b53502
|
7
|
+
data.tar.gz: c098fb760ad6d0fdcbfa2ade102aa2f5afa520c9c74467d2bb043a9257d3c5eae212c6eab6eba4f0cf6ae125ee88bfbcfe503e7304b591176375e613c9f6f199
|
@@ -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,24 @@
|
|
47
45
|
}
|
48
46
|
}
|
49
47
|
|
48
|
+
function _getIcon() {
|
49
|
+
// NOTE: retrieved from server, not present in the resources of this plugin
|
50
|
+
// var iconUrl = "/assets/images/music-map/music-icon.png"
|
51
|
+
var defaultIconSize = [48,48];
|
52
|
+
if("iconPath" in tagInputArg) {
|
53
|
+
var iconSizePixels = defaultIconSize;
|
54
|
+
if("iconSize" in tagInputArg) {
|
55
|
+
iconSizePixels = tagInputArg.iconSize;
|
56
|
+
}
|
57
|
+
return L.icon({
|
58
|
+
iconUrl: tagInputArg.iconPath,
|
59
|
+
iconSize: iconSizePixels
|
60
|
+
});
|
61
|
+
} else {
|
62
|
+
return null;
|
63
|
+
}
|
64
|
+
}
|
65
|
+
|
50
66
|
function _getProviderBasemap(){
|
51
67
|
var defaultProviderBasemap = "OpenStreetMap.Mapnik";
|
52
68
|
if("providerBasemap" in tagInputArg){
|
@@ -56,34 +72,57 @@
|
|
56
72
|
}
|
57
73
|
}
|
58
74
|
|
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
|
-
|
75
|
+
function _mapMarkerPopup(leafletItem) {
|
72
76
|
var potentialPopup = "";
|
73
|
-
if('
|
74
|
-
|
75
|
-
|
77
|
+
if('city' in leafletItem) {
|
78
|
+
potentialPopup += `<b>${leafletItem.city}</b>`;
|
79
|
+
}
|
80
|
+
if('popupContent' in leafletItem){
|
81
|
+
if(leafletItem.popupContent.length == 1) {
|
82
|
+
potentialPopup += '<br/>';
|
83
|
+
potentialPopup += leafletItem.popupContent[0];
|
84
|
+
} else {
|
85
|
+
potentialPopup += '<ul>';
|
86
|
+
leafletItem.popupContent.forEach(item => {
|
76
87
|
potentialPopup += '<li>'
|
77
88
|
potentialPopup += item.trim();
|
78
89
|
potentialPopup += '</li>';
|
79
90
|
});
|
80
91
|
potentialPopup += '</ul>';
|
92
|
+
}
|
81
93
|
}
|
82
|
-
if('href' in
|
83
|
-
potentialPopup += '<a href="' +
|
94
|
+
if('href' in leafletItem){
|
95
|
+
potentialPopup += '<a href="' + leafletItem.href + '">' +
|
84
96
|
'<img src="' + newWindowImgSrcBase64 + '"></img></a>';}
|
85
|
-
|
86
|
-
|
97
|
+
return potentialPopup;
|
98
|
+
}
|
99
|
+
|
100
|
+
function _markerProps(icon, leafletValue) {
|
101
|
+
var props = {};
|
102
|
+
if(icon) {
|
103
|
+
props.icon = icon;
|
104
|
+
}
|
105
|
+
props.title = "";
|
106
|
+
if('city' in leafletValue) {
|
107
|
+
props.title = leafletValue.city;
|
108
|
+
}
|
109
|
+
if('popupContent' in leafletValue) {
|
110
|
+
props.title = leafletValue.popupContent;
|
111
|
+
}
|
112
|
+
return props;
|
113
|
+
}
|
114
|
+
|
115
|
+
|
116
|
+
function _mapMarker(leafletItem, map){
|
117
|
+
var m = leafletItem.value;
|
118
|
+
var icon = _getIcon();
|
119
|
+
var markerProps = _markerProps(icon, m);
|
120
|
+
var marker = L.marker([m.latitude, m.longitude], markerProps);
|
121
|
+
var popup = _mapMarkerPopup(m);
|
122
|
+
|
123
|
+
if(popup){
|
124
|
+
marker.bindPopup(popup);
|
125
|
+
}
|
87
126
|
if(!('center' in tagInputArg)){
|
88
127
|
// If the user didn't specify a center, infer from marker
|
89
128
|
map.panTo(new L.LatLng(m.latitude, m.longitude));
|
@@ -95,6 +134,7 @@
|
|
95
134
|
opacity: '0.95'
|
96
135
|
})
|
97
136
|
}
|
137
|
+
return marker;
|
98
138
|
}
|
99
139
|
|
100
140
|
function _onEachFeature(feature, layer){
|
@@ -152,7 +192,8 @@
|
|
152
192
|
function _processLeafletItem(leafletItem, map, markersLayer){
|
153
193
|
switch(leafletItem.type){
|
154
194
|
case "LeafletMarker":
|
155
|
-
|
195
|
+
var marker = _mapMarker(leafletItem, map);
|
196
|
+
markersLayer.addLayer(marker);
|
156
197
|
break;
|
157
198
|
case "LeafletGeoJSON":
|
158
199
|
_addGeoJSONToMap(leafletItem, map);
|
@@ -218,6 +259,16 @@
|
|
218
259
|
}
|
219
260
|
}
|
220
261
|
|
262
|
+
function _addCssStylesheetToDom(elementId, stylesheetPath) {
|
263
|
+
var leafletCssEl = document.createElement("link");
|
264
|
+
leafletCssEl.id = elementId;
|
265
|
+
leafletCssEl.rel = "stylesheet";
|
266
|
+
leafletCssEl.href = stylesheetPath;
|
267
|
+
if(!document.getElementById(leafletCssEl.id)){
|
268
|
+
document.head.appendChild(leafletCssEl);
|
269
|
+
}
|
270
|
+
}
|
271
|
+
|
221
272
|
var leafletCssId = "leaflet-css-head";
|
222
273
|
var leafletJsId = "leaflet-js-head";
|
223
274
|
var leafletSearchCssId = "leaflet-search-css-head";
|
@@ -225,22 +276,8 @@
|
|
225
276
|
var esriLeafletJsId = "esri-leaflet-js-head";
|
226
277
|
var leafletProvidersJsId = "leaflet-providers-js-head";
|
227
278
|
|
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
|
-
}
|
279
|
+
_addCssStylesheetToDom(leafletCssId, leafletCdn + "leaflet.css");
|
280
|
+
_addCssStylesheetToDom(leafletSearchCssId, leafletSearchCdn + "leaflet-search.min.css");
|
244
281
|
|
245
282
|
function addToHeadIfNotLoaded(el) {
|
246
283
|
//Add the el to the head if it doesn't exist already. If it does,
|