@bmlt-enabled/croutonjs 3.22.3 → 3.23.0

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-map.js CHANGED
@@ -25,11 +25,22 @@ function MapDelegate(config) {
25
25
  iconAnchor: [12, 32], // point of the icon which will correspond to marker's location
26
26
  shadowAnchor: [12, 32], // the same for the shadow
27
27
  popupAnchor: [12, -32] // point from which the popup should open relative to the iconAnchor
28
+ });
29
+ var g_icon_image_searchpoimt = L.icon({
30
+ iconUrl: config.BMLTPlugin_images+"/SearchPoint.png",
31
+ shadowUrl: config.BMLTPlugin_images+"/NAMarkerS.png",
32
+ iconSize: [23, 32], // size of the icon
33
+ shadowSize: [43, 32], // size of the shadow
34
+ iconAnchor: [12, 32], // point of the icon which will correspond to marker's location
35
+ shadowAnchor: [12, 32], // the same for the shadow
36
+ popupAnchor: [12, -32] // point from which the popup should open relative to the iconAnchor
28
37
  });
29
38
  var gAllMarkers = []; ///< Holds all the markers.
30
39
  var gMainMap;
31
40
  var gTileLayer;
32
41
  var gClusterLayer = null;
42
+ var gSearchPointMarker = false;
43
+ var gOpenMarker = false;
33
44
  function createMap(inDiv, inCenter, inHidden = false) {
34
45
  if (! inCenter ) return null;
35
46
  if ( inHidden ) {
@@ -123,6 +134,7 @@ function MapDelegate(config) {
123
134
  function getZoomAdjust(only_out,filterMeetings) {
124
135
  if (!gMainMap) return 12;
125
136
  var ret = gMainMap.getZoom();
137
+ if (config.map_search && config.filter_visible) return ret;
126
138
  var center = gMainMap.getCenter();
127
139
  var bounds = gMainMap.getBounds();
128
140
  var zoomedOut = false;
@@ -171,18 +183,26 @@ function MapDelegate(config) {
171
183
  if (!gMainMap) return null;
172
184
  return gMainMap.latLngToLayerPoint(L.latLng(lat,lng));
173
185
  }
186
+ function markSearchPoint(inCoords) {
187
+ if (!gMainMap) return;
188
+ if (gSearchPointMarker) gSearchPointMarker.remove();
189
+ gSearchPointMarker = L.marker(inCoords, {icon: g_icon_image_searchpoimt});
190
+ gSearchPointMarker.addTo(gMainMap);
191
+ }
174
192
  function createMarker ( inCoords, ///< The long/lat for the marker.
175
193
  multi, ///< Flag if marker has multiple meetings
176
194
  in_html, ///< The info window HTML
177
195
  in_title, ///< The tooltip
178
- in_ids
196
+ in_ids,
197
+ openedMarker
179
198
  )
180
199
  {
181
200
  if (!gMainMap) return;
182
201
  var in_main_icon = (multi ? g_icon_image_multi : g_icon_image_single);
183
202
 
184
203
  let highlightRow = function(target) {
185
- let id = target.id.split('-')[1];
204
+ const id = target.id.split('-')[1];
205
+ gOpenMarker = id;
186
206
  jQuery(".bmlt-data-row > td").removeClass("rowHighlight");
187
207
  jQuery("#meeting-data-row-" + id + " > td").addClass("rowHighlight");
188
208
  if (typeof crouton != 'undefined') crouton.dayTabFromId(id);
@@ -192,6 +212,16 @@ function MapDelegate(config) {
192
212
  if (gClusterLayer) gClusterLayer.addLayer(marker);
193
213
  else marker.addTo(gMainMap);
194
214
  marker.on('popupopen', function(e) {
215
+ if (openedMarker && marker.getPopup().getContent().includes("panel-"+openedMarker)) {
216
+ // I want to just do this:
217
+ //jQuery("#panel-"+openedMarker).prop("checked", true);
218
+ // But for some reason, leaflet makes a copy of the popup, so the ID is not unique....
219
+ jQuery("input[type=radio][name=panel]").filter(function() {
220
+ return jQuery(this).attr('id')=="panel-"+openedMarker})
221
+ .each(function(index,value) {
222
+ jQuery(this).prop("checked", true);
223
+ });
224
+ }
195
225
  marker.setIcon(g_icon_image_selected);
196
226
  gMainMap.on('zoomstart',function(){
197
227
  marker.closePopup();
@@ -204,11 +234,21 @@ function MapDelegate(config) {
204
234
  });
205
235
  });
206
236
  marker.on('popupclose', function(e) {
237
+ gOpenMarker = false;
207
238
  marker.setIcon(marker.isMulti ? g_icon_image_multi : g_icon_image_single);
208
239
  jQuery(".bmlt-data-row > td").removeClass("rowHighlight");
209
240
  });
241
+ if (openedMarker && in_ids.includes(parseInt(openedMarker))) {
242
+ marker.openPopup();
243
+ marker.once('add', function() {
244
+ if (!marker.isPopupOpen()) marker.openPopup();
245
+ });
246
+ }
210
247
  gAllMarkers.push( {ids: in_ids, marker: marker} );
211
248
  }
249
+ function getOpenMarker() {
250
+ return gOpenMarker;
251
+ }
212
252
  function openMarker(id) {
213
253
  if (!gMainMap) return;
214
254
  marker = gAllMarkers.find((m) => m.ids.includes(id));
@@ -406,6 +446,19 @@ function addControl(div,pos,cb) {
406
446
  })
407
447
  });
408
448
  }
449
+ function getCorners(lat_lngs = false) {
450
+ var bounds = lat_lngs
451
+ ? lat_lngs.reduce(function(b,lat_lng) {b.extend(lat_lng); return b;}, L.latLngBounds())
452
+ : gMainMap.getBounds();
453
+
454
+ return {
455
+ "ne" : {"lat": bounds.getNorthEast().lat, "lng": bounds.getNorthEast().lng},
456
+ "sw" : {"lat": bounds.getSouthWest().lat, "lng": bounds.getSouthWest().lng}
457
+ }
458
+ }
459
+ function getCenter() {
460
+ return {"lat": gMainMap.getCenter().lat, "lng": gMainMap.getCenter().lng};
461
+ }
409
462
  function modalOn() {
410
463
  if (gMainMap) gMainMap.dragging.disable()
411
464
  }
@@ -416,8 +469,8 @@ function addControl(div,pos,cb) {
416
469
  f();
417
470
  }
418
471
  function returnTrue() {return true;}
419
- function hasClickSearch() {
420
- return gMainMap != null;
472
+ function isMapDefined() {
473
+ return (gMainMap != null);
421
474
  }
422
475
  this.createMap = createMap;
423
476
  this.addListener = addListener;
@@ -445,7 +498,11 @@ function addControl(div,pos,cb) {
445
498
  this.modalOn = modalOn;
446
499
  this.modalOff = modalOff;
447
500
  this.afterInit = afterInit;
448
- this.hasClickSearch = hasClickSearch;
501
+ this.isMapDefined = isMapDefined;
502
+ this.getCorners = getCorners;
503
+ this.getCenter = getCenter;
504
+ this.markSearchPoint = markSearchPoint;
505
+ this.getOpenMarker = getOpenMarker;
449
506
  }
450
507
  MapDelegate.prototype.createMap = null;
451
508
  MapDelegate.prototype.addListener = null;
@@ -473,8 +530,11 @@ MapDelegate.prototype.getGeocodeCenter = null;
473
530
  MapDelegate.prototype.modalOn = null;
474
531
  MapDelegate.prototype.modalOff = null;
475
532
  MapDelegate.prototype.afterInit = null;
476
- MapDelegate.prototype.hasClickSearch = null;
477
-
533
+ MapDelegate.prototype.isMapDefined = null;
534
+ MapDelegate.prototype.getCorners = null;
535
+ MapDelegate.prototype.getCenter = null;
536
+ MapDelegate.prototype.markSearchPoint = null;
537
+ MapDelegate.prototype.getOpenMarker = null;
478
538
  /* @preserve
479
539
  * Leaflet 1.5.1+Detached: 2e3e0ffbe87f246eb76d86d2633ddd59b262830b.2e3e0ff, a JS library for interactive maps. http://leafletjs.com
480
540
  * (c) 2010-2018 Vladimir Agafonkin, (c) 2010-2011 CloudMade