@abi-software/flatmap-viewer 2.2.12-b.2 → 2.2.12-b.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.
package/README.rst CHANGED
@@ -38,7 +38,7 @@ The map server endpoint is specified as ``MAP_ENDPOINT`` in ``src/main.js``. It
38
38
  Package Installation
39
39
  ====================
40
40
 
41
- * ``npm install @abi-software/flatmap-viewer@2.2.12-b.2``
41
+ * ``npm install @abi-software/flatmap-viewer@2.2.12-b.4``
42
42
 
43
43
  Documentation
44
44
  -------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abi-software/flatmap-viewer",
3
- "version": "2.2.12-b.2",
3
+ "version": "2.2.12-b.4",
4
4
  "description": "Flatmap viewer using Maplibre GL",
5
5
  "repository": "https://github.com/AnatomicMaps/flatmap-viewer.git",
6
6
  "main": "src/main.js",
@@ -802,19 +802,21 @@ class FlatMap
802
802
  /**
803
803
  * Add a marker to the map.
804
804
  *
805
- * @param {string} anatomicalId The anatomical identifier of the feature on which
806
- * to place the marker
807
- * @param {string} [htmlElement=null] An optional parameter giving the DOM element to
808
- * use as a marker. The default is a light blue,
809
- * droplet-shaped SVG marker.
810
- * @return {integer} The identifier for the resulting marker. -1 is returned if the
811
- * map doesn't contain a feature with the given anatomical identifier
805
+ * @param {string} anatomicalId The anatomical identifier of the feature on which
806
+ * to place the marker.
807
+ * @arg {Object} options Configurable options for the marker.
808
+ * @arg {string} options.colour Colour of the default marker. Defaults to ``'#005974'``
809
+ * (dark blue).
810
+ * @arg {string} options.element The DOM element to use as a marker. The default is
811
+ * a dark blue droplet-shaped SVG marker.
812
+ * @return {integer} The identifier for the resulting marker. -1 is returned if the
813
+ * map doesn't contain a feature with the given anatomical identifier
812
814
  */
813
- addMarker(anatomicalId, htmlElement=null)
814
- //========================================
815
+ addMarker(anatomicalId, options={})
816
+ //==================================
815
817
  {
816
818
  if (this._userInteractions !== null) {
817
- return this._userInteractions.addMarker(anatomicalId, htmlElement);
819
+ return this._userInteractions.addMarker(anatomicalId, options);
818
820
  }
819
821
  return -1;
820
822
  }
@@ -193,22 +193,6 @@ export class UserInteractions
193
193
  }
194
194
  }
195
195
 
196
- // Display a context menu on right-click
197
-
198
- this._lastContextTime = 0;
199
- this._contextMenu = new ContextMenu(flatmap, this.__clearModal.bind(this));
200
- this._map.on('contextmenu', this.contextMenuEvent_.bind(this));
201
-
202
- // Display a context menu with a touch longer than 0.5 second
203
-
204
- this._lastTouchTime = 0;
205
- this._map.on('touchstart', (e) => { this._lastTouchTime = Date.now(); });
206
- this._map.on('touchend', (e) => {
207
- if (Date.now() > (this._lastTouchTime + 500)) {
208
- this.contextMenuEvent_(e);
209
- }
210
- });
211
-
212
196
  // Handle mouse events
213
197
 
214
198
  this._map.on('click', this.clickEvent_.bind(this));
@@ -424,45 +408,6 @@ export class UserInteractions
424
408
  return smallestFeature;
425
409
  }
426
410
 
427
- contextMenuEvent_(event)
428
- //======================
429
- {
430
- event.preventDefault();
431
-
432
- // Chrome on Android sends both touch and contextmenu events
433
- // so ignore duplicate
434
-
435
- if (Date.now() < (this._lastContextTime + 100)) {
436
- return;
437
- }
438
- this._lastContextTime = Date.now();
439
-
440
- if (this._activeFeatures.length > 0) {
441
- const feature = this._activeFeatures[0];
442
-
443
- // Remove any tooltip
444
- this.removeTooltip_();
445
-
446
- const featureId = feature.id;
447
- if (this._pathways.isNode(featureId)) {
448
- const items = [
449
- {
450
- featureId: featureId,
451
- prompt: 'Show paths',
452
- action: this.enablePaths_.bind(this, true)
453
- },
454
- {
455
- featureId: featureId,
456
- prompt: 'Hide paths',
457
- action: this.enablePaths_.bind(this, false)
458
- }
459
- ];
460
- this.setModal_();
461
- this._contextMenu.show(event.lngLat, items, feature.properties.label);
462
- }
463
- }
464
- }
465
-
466
411
  setModal_(event)
467
412
  //==============
468
413
  {
@@ -982,7 +927,6 @@ export class UserInteractions
982
927
  enablePaths_(enable, event)
983
928
  //=========================
984
929
  {
985
- this._contextMenu.hide();
986
930
  const nodeId = event.target.getAttribute('featureId');
987
931
  this.enablePathFeatures_(enable, this._pathways.pathFeatureIds(nodeId));
988
932
  this.__clearModal();
@@ -1086,8 +1030,8 @@ export class UserInteractions
1086
1030
  return position;
1087
1031
  }
1088
1032
 
1089
- addMarker(anatomicalId, htmlElement=null)
1090
- //=======================================
1033
+ addMarker(anatomicalId, options={})
1034
+ //=================================
1091
1035
  {
1092
1036
  const featureIds = this._flatmap.modelFeatureIds(anatomicalId);
1093
1037
  let markerId = -1;
@@ -1106,8 +1050,9 @@ export class UserInteractions
1106
1050
  // MapLibre dynamically sets a transform on marker elements so in
1107
1051
  // order to apply a scale transform we need to create marker icons
1108
1052
  // inside the marker container <div>.
1109
- const markerHTML = htmlElement ? new maplibre.Marker({element: htmlElement})
1110
- : new maplibre.Marker();
1053
+ const colour = options.colour || '#005974';
1054
+ const markerHTML = options.element ? new maplibre.Marker({element: options.element})
1055
+ : new maplibre.Marker({color: colour});
1111
1056
 
1112
1057
  const markerElement = document.createElement('div');
1113
1058
  const markerIcon = document.createElement('div');