@bmlt-enabled/croutonjs 4.1.11 → 4.3.1
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 +61 -7
- package/crouton-core.min.css +1 -1
- package/crouton-gmaps.js +1074 -675
- package/crouton-gmaps.min.js +36 -12
- package/crouton-gmaps.min.js.map +1 -1
- package/crouton-map.js +81 -90
- package/crouton-map.min.js +1 -1
- package/crouton-map.min.js.map +1 -1
- package/crouton.css +61 -7
- package/crouton.js +1062 -667
- package/crouton.min.css +1 -1
- package/crouton.min.js +34 -10
- package/crouton.min.js.map +1 -1
- package/crouton.nojquery.js +981 -577
- 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(
|
|
@@ -387,36 +367,42 @@ function addControl(div,pos,cb) {
|
|
|
387
367
|
properties: data[i]
|
|
388
368
|
};
|
|
389
369
|
}
|
|
390
|
-
|
|
391
|
-
else cb(results);
|
|
370
|
+
cb(results);
|
|
392
371
|
} else {
|
|
393
372
|
alert ( crouton.localization.getWord("address_lookup_fail") );
|
|
394
373
|
}
|
|
395
374
|
}, this)
|
|
396
375
|
);
|
|
397
376
|
};
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
377
|
+
function getGeocodingChoices(in_geocode_response) {
|
|
378
|
+
if (!Array.isArray(in_geocode_response)) return [];
|
|
379
|
+
return in_geocode_response.map((r) => r.name);
|
|
380
|
+
}
|
|
381
|
+
function getZoomAdjustedBounds(center, filterMeetings, zoomLevel) {
|
|
382
|
+
const mapWidth = calcOffsetWidth(gDiv);
|
|
383
|
+
const mapHeight = parseInt(jQuery(gDiv).css("height").replace("px",""));
|
|
384
|
+
if (center) {
|
|
385
|
+
const zoom = getZoomAdjust(filterMeetings, zoomLevel, center);
|
|
386
|
+
const bounds = calculateBounds(center, zoom, mapWidth, mapHeight);
|
|
387
|
+
const ret = {"center": center, "bounds": bounds, "zoom": zoom};
|
|
388
|
+
return ret;
|
|
389
|
+
} else {
|
|
390
|
+
alert ( crouton.localization.getWord("address_lookup_fail") );
|
|
391
|
+
return null;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
function getGeocodeCenterAndBounds (in_geocode_response, i=0) {
|
|
395
|
+
if ( in_geocode_response && in_geocode_response[i] ) {
|
|
396
|
+
return {
|
|
397
|
+
center: {lat: in_geocode_response[i].center.lat, lng: in_geocode_response[i].center.lng},
|
|
398
|
+
southWest: {lat: in_geocode_response[i].bbox.getSouthWest().lat, lng: in_geocode_response[i].bbox.getSouthWest().lng},
|
|
399
|
+
northEast: {lat: in_geocode_response[i].bbox.getNorthEast().lat, lng: in_geocode_response[i].bbox.getNorthEast().lng},
|
|
400
|
+
};
|
|
415
401
|
} else {
|
|
416
402
|
alert ( crouton.localization.getWord("address_lookup_fail") );
|
|
417
403
|
};
|
|
418
404
|
};
|
|
419
|
-
function callGeocoder(in_loc,
|
|
405
|
+
function callGeocoder(in_loc, callback) {
|
|
420
406
|
geoCodeParams = {};
|
|
421
407
|
if (config.region && config.region.trim() !== '') {
|
|
422
408
|
geoCodeParams.countrycodes = config.region;
|
|
@@ -429,7 +415,7 @@ function addControl(div,pos,cb) {
|
|
|
429
415
|
geoCodeParams.viewbox = config.bounds.west+","+config.bounds.south+","+
|
|
430
416
|
config.bounds.east+","+config.bounds.north;
|
|
431
417
|
}
|
|
432
|
-
geocode(in_loc, geoCodeParams, callback
|
|
418
|
+
geocode(in_loc, geoCodeParams, callback);
|
|
433
419
|
}
|
|
434
420
|
function isNumber(x) {
|
|
435
421
|
if (typeof x === 'number') return true;
|
|
@@ -494,22 +480,24 @@ function addControl(div,pos,cb) {
|
|
|
494
480
|
function modalOff() {
|
|
495
481
|
if (gMainMap) gMainMap.dragging.enable()
|
|
496
482
|
}
|
|
497
|
-
function afterInit(f) {
|
|
483
|
+
function afterInit(doNotWait, f) {
|
|
498
484
|
f();
|
|
499
485
|
}
|
|
500
486
|
function returnTrue() {return true;}
|
|
501
487
|
function isMapDefined() {
|
|
502
|
-
return (gMainMap
|
|
488
|
+
return (gMainMap !== null);
|
|
489
|
+
}
|
|
490
|
+
function isMapVisible() {
|
|
491
|
+
return (gMainMap !== null) && gMainMap.getSize().x > 0 && gMainMap.getSize().y > 0;
|
|
503
492
|
}
|
|
504
493
|
this.createMap = createMap;
|
|
505
494
|
this.addListener = addListener;
|
|
506
495
|
this.removeListener = removeListener;
|
|
507
496
|
this.addControl = addControl;
|
|
508
|
-
|
|
497
|
+
this.flyToFixedZoom = flyToFixedZoom;
|
|
509
498
|
this.clearAllMarkers = clearAllMarkers;
|
|
510
|
-
this.fromLatLngToPoint = fromLatLngToPoint;
|
|
511
499
|
this.callGeocoder = callGeocoder;
|
|
512
|
-
this.
|
|
500
|
+
this.getZoomAdjustedBounds = getZoomAdjustedBounds;
|
|
513
501
|
this.getZoom = getZoom;
|
|
514
502
|
this.createMarker = createMarker;
|
|
515
503
|
this.bindPopup = bindPopup;
|
|
@@ -517,7 +505,6 @@ function addControl(div,pos,cb) {
|
|
|
517
505
|
this.contains = contains;
|
|
518
506
|
this.getBounds = getBounds;
|
|
519
507
|
this.invalidateSize = invalidateSize;
|
|
520
|
-
this.zoomOut = zoomOut;
|
|
521
508
|
this.fitBounds = fitBounds;
|
|
522
509
|
this.openMarker = openMarker;
|
|
523
510
|
this.isApiLoaded = returnTrue;
|
|
@@ -525,33 +512,34 @@ function addControl(div,pos,cb) {
|
|
|
525
512
|
this.addClusterLayer = addClusterLayer;
|
|
526
513
|
this.removeClusterLayer = removeClusterLayer;
|
|
527
514
|
this.clickSearch = clickSearch;
|
|
528
|
-
this.
|
|
515
|
+
this.getGeocodeCenterAndBounds = getGeocodeCenterAndBounds;
|
|
516
|
+
this.getGeocodingChoices = getGeocodingChoices;
|
|
529
517
|
this.modalOn = modalOn;
|
|
530
518
|
this.modalOff = modalOff;
|
|
531
519
|
this.afterInit = afterInit;
|
|
532
520
|
this.isMapDefined = isMapDefined;
|
|
521
|
+
this.isMapVisible = isMapVisible;
|
|
533
522
|
this.getCorners = getCorners;
|
|
534
523
|
this.getCenter = getCenter;
|
|
535
524
|
this.markSearchPoint = markSearchPoint;
|
|
536
525
|
this.getOpenMarker = getOpenMarker;
|
|
526
|
+
this.calculateBoundsFromCenterAndZoom = calculateBoundsFromCenterAndZoom;
|
|
537
527
|
}
|
|
538
528
|
MapDelegate.prototype.createMap = null;
|
|
539
529
|
MapDelegate.prototype.addListener = null;
|
|
540
530
|
MapDelegate.prototype.removeListener = null;
|
|
541
531
|
MapDelegate.prototype.addControl = null;
|
|
542
|
-
MapDelegate.prototype.
|
|
532
|
+
MapDelegate.prototype.flyToFixedZoom = null;
|
|
543
533
|
MapDelegate.prototype.clearAllMarkers = null;
|
|
544
|
-
MapDelegate.prototype.fromLatLngToPoint = null;
|
|
545
534
|
MapDelegate.prototype.callGeocoder = null;
|
|
546
|
-
MapDelegate.prototype.setZoom = null;
|
|
547
535
|
MapDelegate.prototype.getZoom = null;
|
|
536
|
+
MapDelegate.prototype.getZoomAdjustedBounds = null;
|
|
548
537
|
MapDelegate.prototype.createMarker = null;
|
|
549
538
|
MapDelegate.prototype.bindPopup = null;
|
|
550
539
|
MapDelegate.prototype.addMarkerCallback = null;
|
|
551
540
|
MapDelegate.prototype.contains = null;
|
|
552
541
|
MapDelegate.prototype.getBounds = null;
|
|
553
542
|
MapDelegate.prototype.invalidateSize = null;
|
|
554
|
-
MapDelegate.prototype.zoomOut = null;
|
|
555
543
|
MapDelegate.prototype.fitBounds = null;
|
|
556
544
|
MapDelegate.prototype.openMarker = null;
|
|
557
545
|
MapDelegate.prototype.isApiLoaded = null;
|
|
@@ -559,15 +547,18 @@ MapDelegate.prototype.createClusterLayer = null;
|
|
|
559
547
|
MapDelegate.prototype.addClusterLayer = null;
|
|
560
548
|
MapDelegate.prototype.removeClusterLayer = null;
|
|
561
549
|
MapDelegate.prototype.clickSearch = null;
|
|
562
|
-
MapDelegate.prototype.
|
|
550
|
+
MapDelegate.prototype.getGeocodeCenterAndBounds = null;
|
|
551
|
+
MapDelegate.prototype.getGeocodingChoices = null;
|
|
563
552
|
MapDelegate.prototype.modalOn = null;
|
|
564
553
|
MapDelegate.prototype.modalOff = null;
|
|
565
554
|
MapDelegate.prototype.afterInit = null;
|
|
566
555
|
MapDelegate.prototype.isMapDefined = null;
|
|
556
|
+
MapDelegate.prototype.isMapVisible = null;
|
|
567
557
|
MapDelegate.prototype.getCorners = null;
|
|
568
558
|
MapDelegate.prototype.getCenter = null;
|
|
569
559
|
MapDelegate.prototype.markSearchPoint = null;
|
|
570
560
|
MapDelegate.prototype.getOpenMarker = null;
|
|
561
|
+
MapDelegate.prototype.calculateBoundsFromCenterAndZoom = null;
|
|
571
562
|
/* @preserve
|
|
572
563
|
* Leaflet 1.9.4+v1.d15112c, a JS library for interactive maps. https://leafletjs.com
|
|
573
564
|
* (c) 2010-2023 Vladimir Agafonkin, (c) 2010-2011 CloudMade
|