@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 +1 -1
- package/package.json +1 -1
- package/src/flatmap-viewer.js +12 -10
- package/src/interactions.js +5 -60
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.
|
|
41
|
+
* ``npm install @abi-software/flatmap-viewer@2.2.12-b.4``
|
|
42
42
|
|
|
43
43
|
Documentation
|
|
44
44
|
-------------
|
package/package.json
CHANGED
package/src/flatmap-viewer.js
CHANGED
|
@@ -802,19 +802,21 @@ class FlatMap
|
|
|
802
802
|
/**
|
|
803
803
|
* Add a marker to the map.
|
|
804
804
|
*
|
|
805
|
-
* @param
|
|
806
|
-
*
|
|
807
|
-
* @
|
|
808
|
-
*
|
|
809
|
-
*
|
|
810
|
-
* @
|
|
811
|
-
*
|
|
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,
|
|
814
|
-
|
|
815
|
+
addMarker(anatomicalId, options={})
|
|
816
|
+
//==================================
|
|
815
817
|
{
|
|
816
818
|
if (this._userInteractions !== null) {
|
|
817
|
-
return this._userInteractions.addMarker(anatomicalId,
|
|
819
|
+
return this._userInteractions.addMarker(anatomicalId, options);
|
|
818
820
|
}
|
|
819
821
|
return -1;
|
|
820
822
|
}
|
package/src/interactions.js
CHANGED
|
@@ -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,
|
|
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
|
|
1110
|
-
|
|
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');
|