@bmlt-enabled/croutonjs 4.1.12 → 4.3.2
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.
- package/crouton-core.css +89 -11
- package/crouton-core.min.css +1 -1
- package/crouton-gmaps.js +1185 -677
- package/crouton-gmaps.min.js +36 -12
- package/crouton-gmaps.min.js.map +1 -1
- package/crouton-map.js +95 -103
- package/crouton-map.min.js +1 -1
- package/crouton-map.min.js.map +1 -1
- package/crouton.css +89 -11
- package/crouton.js +1187 -682
- package/crouton.min.css +1 -1
- package/crouton.min.js +34 -10
- package/crouton.min.js.map +1 -1
- package/crouton.nojquery.js +1092 -579
- package/crouton.nojquery.min.js +36 -12
- package/crouton.nojquery.min.js.map +1 -1
- package/package.json +1 -1
- package/templates/themes/florida-nights.css +2 -2
- package/templates/themes/frog.css +2 -2
- package/templates/themes/one-nine.css +2 -2
- package/templates/themes/seattle-rain.css +2 -2
- package/templates/themes/truth.css +2 -2
package/crouton-map.js
CHANGED
|
@@ -52,10 +52,11 @@ function MapDelegate(config) {
|
|
|
52
52
|
var gClusterLayer = null;
|
|
53
53
|
var gSearchPointMarker = false;
|
|
54
54
|
var gOpenMarker = false;
|
|
55
|
+
var gDiv = null;
|
|
55
56
|
function createMap(inDiv, inCenter, inHidden = false) {
|
|
56
57
|
if (! inCenter ) return null;
|
|
57
|
-
if ( inHidden ) {
|
|
58
58
|
gDiv = inDiv;
|
|
59
|
+
if ( inHidden ) {
|
|
59
60
|
gDiv.style.height = 'auto';
|
|
60
61
|
gDiv.style.marginBottom = '10px';
|
|
61
62
|
gMainMap = null;
|
|
@@ -111,26 +112,24 @@ function MapDelegate(config) {
|
|
|
111
112
|
if (!gMainMap) return;
|
|
112
113
|
gMainMap.off(o.event, o.f);
|
|
113
114
|
}
|
|
114
|
-
|
|
115
|
+
function flyToFixedZoom(position, zoomLevel, extra=null) {
|
|
115
116
|
if (!gMainMap) return;
|
|
116
|
-
|
|
117
|
-
|
|
117
|
+
|
|
118
|
+
const latlng = L.latLng(position.lat, position.lng);
|
|
118
119
|
gMainMap.once('moveend', function(ev) {
|
|
119
|
-
|
|
120
|
-
if (gMainMap.getZoom() != newZoom) {
|
|
121
|
-
gMainMap.setZoom(newZoom);
|
|
120
|
+
if (gMainMap.getZoom() != zoomLevel) {
|
|
122
121
|
gMainMap.once('zoomend',function() {
|
|
123
122
|
gMainMap.invalidateSize();
|
|
124
123
|
if (extra) {
|
|
125
124
|
gMainMap.once('load moveend', extra);
|
|
126
125
|
}
|
|
127
126
|
});
|
|
127
|
+
gMainMap.setZoom(zoomLevel);
|
|
128
128
|
} else {
|
|
129
|
-
if (extra)
|
|
130
|
-
extra();
|
|
131
|
-
}
|
|
129
|
+
if (extra) extra();
|
|
132
130
|
}
|
|
133
131
|
});
|
|
132
|
+
gMainMap.flyTo(latlng, zoomLevel);
|
|
134
133
|
}
|
|
135
134
|
function clearAllMarkers ( )
|
|
136
135
|
{
|
|
@@ -145,58 +144,39 @@ function MapDelegate(config) {
|
|
|
145
144
|
function isFilterVisible() {
|
|
146
145
|
return config.filter_visible && config.filter_visible == 1;
|
|
147
146
|
}
|
|
148
|
-
function
|
|
147
|
+
function webMercatorToLatLng(point, zoom) {
|
|
148
|
+
const latLng = croutonMap.webMercatorToLatLng(point, zoom);
|
|
149
|
+
return L.latLng(latLng.lat, latLng.lng);
|
|
150
|
+
}
|
|
151
|
+
function calculateBounds(center, zoom, width, height) {
|
|
152
|
+
const centerPoint = croutonMap.latLngToWebMercator(center, zoom);
|
|
153
|
+
const northeastWebMercator = {x: centerPoint.x-width/2, y: centerPoint.y-height/2};
|
|
154
|
+
const southwestWebMercator = {x: centerPoint.x+width/2, y: centerPoint.y+height/2};
|
|
155
|
+
return L.latLngBounds(webMercatorToLatLng(southwestWebMercator, zoom), webMercatorToLatLng(northeastWebMercator, zoom));
|
|
156
|
+
}
|
|
157
|
+
function calcOffsetWidth(gDiv) {
|
|
158
|
+
let ret = gDiv.offsetWidth;
|
|
159
|
+
if (ret === 0) ret = gDiv.parentElement.offsetWidth;
|
|
160
|
+
return ret;
|
|
161
|
+
}
|
|
162
|
+
function calculateBoundsFromCenterAndZoom(center, zoomLevel) {
|
|
163
|
+
const mapWidth = calcOffsetWidth(gDiv);
|
|
164
|
+
const mapHeight = parseInt(jQuery(gDiv).css("height").replace("px",""));
|
|
165
|
+
return calculateBounds(center, zoomLevel, mapWidth, mapHeight);
|
|
166
|
+
}
|
|
167
|
+
function getZoomAdjust(filterMeetings,zoomLevel=gMainMap.getZoom(), center=gMainMap.getCenter()) {
|
|
149
168
|
if (!gMainMap) return 12;
|
|
150
|
-
|
|
169
|
+
const mapWidth = calcOffsetWidth(gDiv);
|
|
170
|
+
const mapHeight = parseInt(jQuery(gDiv).css("height").replace("px",""));
|
|
171
|
+
ret = zoomLevel;
|
|
151
172
|
if (config.map_search && isFilterVisible()) return ret;
|
|
152
|
-
var
|
|
153
|
-
|
|
154
|
-
var zoomedOut = false;
|
|
155
|
-
while(filterMeetings(bounds, center).length==0 && ret>6) {
|
|
156
|
-
zoomedOut = true;
|
|
157
|
-
// not exact, because earth is curved
|
|
173
|
+
var bounds = calculateBounds(center, ret, mapWidth, mapHeight);
|
|
174
|
+
while(filterMeetings(bounds, center).length==0 && ret>config.minZoom) {
|
|
158
175
|
ret -= 1;
|
|
159
|
-
|
|
160
|
-
(2*bounds.getNorthEast().lat)-center.lat,
|
|
161
|
-
(2*bounds.getNorthEast().lng)-center.lng);
|
|
162
|
-
var sw = L.latLng(
|
|
163
|
-
(2*bounds.getSouthWest().lat)-center.lat,
|
|
164
|
-
(2*bounds.getSouthWest().lng)-center.lng);
|
|
165
|
-
bounds = L.latLngBounds(sw,ne);
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
if (!only_out && !zoomedOut && ret<12) {
|
|
169
|
-
var knt = filterMeetings(bounds).length;
|
|
170
|
-
while(ret<12 && knt>0) {
|
|
171
|
-
// no exact, because earth is curved
|
|
172
|
-
ret += 1;
|
|
173
|
-
var ne = L.latLng(
|
|
174
|
-
0.5*(bounds.getNorthEast().lat+center.lat),
|
|
175
|
-
0.5*(bounds.getNorthEast().lng+center.lng));
|
|
176
|
-
var sw = L.latLng(
|
|
177
|
-
0.5*(bounds.getSouthWest().lat+center.lat),
|
|
178
|
-
0.5*(bounds.getSouthWest().lng+center.lng));
|
|
179
|
-
bounds = L.latLngBounds(sw,ne);
|
|
180
|
-
knt = filterMeetings(bounds).length;
|
|
181
|
-
}
|
|
182
|
-
if (knt == 0) {
|
|
183
|
-
ret -= 1;
|
|
184
|
-
}
|
|
176
|
+
bounds = calculateBounds(center, ret, mapWidth, mapHeight);
|
|
185
177
|
}
|
|
186
178
|
return ret;
|
|
187
179
|
}
|
|
188
|
-
function setZoom(filterMeetings, force=0) {
|
|
189
|
-
if (!gMainMap) return;
|
|
190
|
-
(force > 0) ? gMainMap.setZoom(force) : gMainMap.setZoom(getZoomAdjust(false,filterMeetings));
|
|
191
|
-
}
|
|
192
|
-
function zoomOut(filterMeetings) {
|
|
193
|
-
if (!gMainMap) return;
|
|
194
|
-
gMainMap.setZoom(getZoomAdjust(true,filterMeetings));
|
|
195
|
-
}
|
|
196
|
-
function fromLatLngToPoint(lat, lng) {
|
|
197
|
-
if (!gMainMap) return null;
|
|
198
|
-
return gMainMap.latLngToLayerPoint(L.latLng(lat,lng));
|
|
199
|
-
}
|
|
200
180
|
function markSearchPoint(inCoords) {
|
|
201
181
|
if (!gMainMap) return;
|
|
202
182
|
if (gSearchPointMarker) gSearchPointMarker.remove();
|
|
@@ -359,7 +339,7 @@ function addControl(div,pos,cb) {
|
|
|
359
339
|
}
|
|
360
340
|
return (!existingUrl || existingUrl.indexOf('?') === -1 ? '?' : '&') + params.join('&');
|
|
361
341
|
}
|
|
362
|
-
function geocode(query, params, cb
|
|
342
|
+
function geocode(query, params, cb) {
|
|
363
343
|
var serviceUrl = config.nominatimUrl;
|
|
364
344
|
if (!serviceUrl) serviceUrl = 'https://nominatim.openstreetmap.org/';
|
|
365
345
|
getJSON(
|
|
@@ -369,54 +349,61 @@ function addControl(div,pos,cb) {
|
|
|
369
349
|
q: query,
|
|
370
350
|
limit: 5,
|
|
371
351
|
format: 'json',
|
|
372
|
-
addressdetails: 1
|
|
352
|
+
addressdetails: 1,
|
|
353
|
+
layer: "address"
|
|
373
354
|
},
|
|
374
355
|
params
|
|
375
356
|
),
|
|
376
357
|
L.bind(function(data) {
|
|
377
|
-
var results = [];
|
|
378
358
|
if (data && data.length) {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
359
|
+
results = data.reduce(function(carry, d) {
|
|
360
|
+
if (!carry.find((item) => item.name === d.display_name)) {
|
|
361
|
+
var bbox = d.boundingbox.map((c) => parseFloat(c));
|
|
362
|
+
carry.push({
|
|
363
|
+
name: d.display_name,
|
|
364
|
+
bbox: L.latLngBounds([bbox[0], bbox[2]], [bbox[1], bbox[3]]),
|
|
365
|
+
center: L.latLng(d.lat, d.lon),
|
|
366
|
+
properties: d
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
return carry;
|
|
370
|
+
}, []);
|
|
371
|
+
cb(results);
|
|
392
372
|
} else {
|
|
393
373
|
alert ( crouton.localization.getWord("address_lookup_fail") );
|
|
394
374
|
}
|
|
395
375
|
}, this)
|
|
396
376
|
);
|
|
397
377
|
};
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
378
|
+
function getGeocodingChoices(in_geocode_response) {
|
|
379
|
+
if (!Array.isArray(in_geocode_response)) return [];
|
|
380
|
+
return in_geocode_response.map((r) => r.name);
|
|
381
|
+
}
|
|
382
|
+
function getZoomAdjustedBounds(center, filterMeetings, zoomLevel) {
|
|
383
|
+
const mapWidth = calcOffsetWidth(gDiv);
|
|
384
|
+
const mapHeight = parseInt(jQuery(gDiv).css("height").replace("px",""));
|
|
385
|
+
if (center) {
|
|
386
|
+
const zoom = getZoomAdjust(filterMeetings, zoomLevel, center);
|
|
387
|
+
const bounds = calculateBounds(center, zoom, mapWidth, mapHeight);
|
|
388
|
+
const ret = {"center": center, "bounds": bounds, "zoom": zoom};
|
|
389
|
+
return ret;
|
|
390
|
+
} else {
|
|
391
|
+
alert ( crouton.localization.getWord("address_lookup_fail") );
|
|
392
|
+
return null;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
function getGeocodeCenterAndBounds (in_geocode_response, i=0) {
|
|
396
|
+
if ( in_geocode_response && in_geocode_response[i] ) {
|
|
397
|
+
return {
|
|
398
|
+
center: {lat: in_geocode_response[i].center.lat, lng: in_geocode_response[i].center.lng},
|
|
399
|
+
southWest: {lat: in_geocode_response[i].bbox.getSouthWest().lat, lng: in_geocode_response[i].bbox.getSouthWest().lng},
|
|
400
|
+
northEast: {lat: in_geocode_response[i].bbox.getNorthEast().lat, lng: in_geocode_response[i].bbox.getNorthEast().lng},
|
|
401
|
+
};
|
|
415
402
|
} else {
|
|
416
403
|
alert ( crouton.localization.getWord("address_lookup_fail") );
|
|
417
404
|
};
|
|
418
405
|
};
|
|
419
|
-
function callGeocoder(in_loc,
|
|
406
|
+
function callGeocoder(in_loc, callback) {
|
|
420
407
|
geoCodeParams = {};
|
|
421
408
|
if (config.region && config.region.trim() !== '') {
|
|
422
409
|
geoCodeParams.countrycodes = config.region;
|
|
@@ -429,7 +416,7 @@ function addControl(div,pos,cb) {
|
|
|
429
416
|
geoCodeParams.viewbox = config.bounds.west+","+config.bounds.south+","+
|
|
430
417
|
config.bounds.east+","+config.bounds.north;
|
|
431
418
|
}
|
|
432
|
-
geocode(in_loc, geoCodeParams, callback
|
|
419
|
+
geocode(in_loc, geoCodeParams, callback);
|
|
433
420
|
}
|
|
434
421
|
function isNumber(x) {
|
|
435
422
|
if (typeof x === 'number') return true;
|
|
@@ -494,22 +481,24 @@ function addControl(div,pos,cb) {
|
|
|
494
481
|
function modalOff() {
|
|
495
482
|
if (gMainMap) gMainMap.dragging.enable()
|
|
496
483
|
}
|
|
497
|
-
function afterInit(f) {
|
|
484
|
+
function afterInit(doNotWait, f) {
|
|
498
485
|
f();
|
|
499
486
|
}
|
|
500
487
|
function returnTrue() {return true;}
|
|
501
488
|
function isMapDefined() {
|
|
502
|
-
return (gMainMap
|
|
489
|
+
return (gMainMap !== null);
|
|
490
|
+
}
|
|
491
|
+
function isMapVisible() {
|
|
492
|
+
return (gMainMap !== null) && gMainMap.getSize().x > 0 && gMainMap.getSize().y > 0;
|
|
503
493
|
}
|
|
504
494
|
this.createMap = createMap;
|
|
505
495
|
this.addListener = addListener;
|
|
506
496
|
this.removeListener = removeListener;
|
|
507
497
|
this.addControl = addControl;
|
|
508
|
-
|
|
498
|
+
this.flyToFixedZoom = flyToFixedZoom;
|
|
509
499
|
this.clearAllMarkers = clearAllMarkers;
|
|
510
|
-
this.fromLatLngToPoint = fromLatLngToPoint;
|
|
511
500
|
this.callGeocoder = callGeocoder;
|
|
512
|
-
this.
|
|
501
|
+
this.getZoomAdjustedBounds = getZoomAdjustedBounds;
|
|
513
502
|
this.getZoom = getZoom;
|
|
514
503
|
this.createMarker = createMarker;
|
|
515
504
|
this.bindPopup = bindPopup;
|
|
@@ -517,7 +506,6 @@ function addControl(div,pos,cb) {
|
|
|
517
506
|
this.contains = contains;
|
|
518
507
|
this.getBounds = getBounds;
|
|
519
508
|
this.invalidateSize = invalidateSize;
|
|
520
|
-
this.zoomOut = zoomOut;
|
|
521
509
|
this.fitBounds = fitBounds;
|
|
522
510
|
this.openMarker = openMarker;
|
|
523
511
|
this.isApiLoaded = returnTrue;
|
|
@@ -525,33 +513,34 @@ function addControl(div,pos,cb) {
|
|
|
525
513
|
this.addClusterLayer = addClusterLayer;
|
|
526
514
|
this.removeClusterLayer = removeClusterLayer;
|
|
527
515
|
this.clickSearch = clickSearch;
|
|
528
|
-
this.
|
|
516
|
+
this.getGeocodeCenterAndBounds = getGeocodeCenterAndBounds;
|
|
517
|
+
this.getGeocodingChoices = getGeocodingChoices;
|
|
529
518
|
this.modalOn = modalOn;
|
|
530
519
|
this.modalOff = modalOff;
|
|
531
520
|
this.afterInit = afterInit;
|
|
532
521
|
this.isMapDefined = isMapDefined;
|
|
522
|
+
this.isMapVisible = isMapVisible;
|
|
533
523
|
this.getCorners = getCorners;
|
|
534
524
|
this.getCenter = getCenter;
|
|
535
525
|
this.markSearchPoint = markSearchPoint;
|
|
536
526
|
this.getOpenMarker = getOpenMarker;
|
|
527
|
+
this.calculateBoundsFromCenterAndZoom = calculateBoundsFromCenterAndZoom;
|
|
537
528
|
}
|
|
538
529
|
MapDelegate.prototype.createMap = null;
|
|
539
530
|
MapDelegate.prototype.addListener = null;
|
|
540
531
|
MapDelegate.prototype.removeListener = null;
|
|
541
532
|
MapDelegate.prototype.addControl = null;
|
|
542
|
-
MapDelegate.prototype.
|
|
533
|
+
MapDelegate.prototype.flyToFixedZoom = null;
|
|
543
534
|
MapDelegate.prototype.clearAllMarkers = null;
|
|
544
|
-
MapDelegate.prototype.fromLatLngToPoint = null;
|
|
545
535
|
MapDelegate.prototype.callGeocoder = null;
|
|
546
|
-
MapDelegate.prototype.setZoom = null;
|
|
547
536
|
MapDelegate.prototype.getZoom = null;
|
|
537
|
+
MapDelegate.prototype.getZoomAdjustedBounds = null;
|
|
548
538
|
MapDelegate.prototype.createMarker = null;
|
|
549
539
|
MapDelegate.prototype.bindPopup = null;
|
|
550
540
|
MapDelegate.prototype.addMarkerCallback = null;
|
|
551
541
|
MapDelegate.prototype.contains = null;
|
|
552
542
|
MapDelegate.prototype.getBounds = null;
|
|
553
543
|
MapDelegate.prototype.invalidateSize = null;
|
|
554
|
-
MapDelegate.prototype.zoomOut = null;
|
|
555
544
|
MapDelegate.prototype.fitBounds = null;
|
|
556
545
|
MapDelegate.prototype.openMarker = null;
|
|
557
546
|
MapDelegate.prototype.isApiLoaded = null;
|
|
@@ -559,15 +548,18 @@ MapDelegate.prototype.createClusterLayer = null;
|
|
|
559
548
|
MapDelegate.prototype.addClusterLayer = null;
|
|
560
549
|
MapDelegate.prototype.removeClusterLayer = null;
|
|
561
550
|
MapDelegate.prototype.clickSearch = null;
|
|
562
|
-
MapDelegate.prototype.
|
|
551
|
+
MapDelegate.prototype.getGeocodeCenterAndBounds = null;
|
|
552
|
+
MapDelegate.prototype.getGeocodingChoices = null;
|
|
563
553
|
MapDelegate.prototype.modalOn = null;
|
|
564
554
|
MapDelegate.prototype.modalOff = null;
|
|
565
555
|
MapDelegate.prototype.afterInit = null;
|
|
566
556
|
MapDelegate.prototype.isMapDefined = null;
|
|
557
|
+
MapDelegate.prototype.isMapVisible = null;
|
|
567
558
|
MapDelegate.prototype.getCorners = null;
|
|
568
559
|
MapDelegate.prototype.getCenter = null;
|
|
569
560
|
MapDelegate.prototype.markSearchPoint = null;
|
|
570
561
|
MapDelegate.prototype.getOpenMarker = null;
|
|
562
|
+
MapDelegate.prototype.calculateBoundsFromCenterAndZoom = null;
|
|
571
563
|
/* @preserve
|
|
572
564
|
* Leaflet 1.9.4+v1.d15112c, a JS library for interactive maps. https://leafletjs.com
|
|
573
565
|
* (c) 2010-2023 Vladimir Agafonkin, (c) 2010-2011 CloudMade
|