@hpcc-js/map 3.6.1 → 3.6.3
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/dist/index.js +129 -103
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +2 -2
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +11 -10
- package/src/GMap.ts +55 -29
- package/src/leaflet/GMap.ts +0 -2
- package/types/GMap.d.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hpcc-js/map",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.3",
|
|
4
4
|
"description": "hpcc-js - Viz Map",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.umd.cjs",
|
|
@@ -41,15 +41,17 @@
|
|
|
41
41
|
"update-major": "npx --yes npm-check-updates -u"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@hpcc-js/api": "^3.5.
|
|
45
|
-
"@hpcc-js/common": "^3.8.
|
|
46
|
-
"@hpcc-js/graph": "^3.8.
|
|
47
|
-
"@hpcc-js/layout": "^3.6.
|
|
48
|
-
"@hpcc-js/other": "^3.6.
|
|
49
|
-
"@hpcc-js/util": "^3.6.
|
|
44
|
+
"@hpcc-js/api": "^3.5.3",
|
|
45
|
+
"@hpcc-js/common": "^3.8.3",
|
|
46
|
+
"@hpcc-js/graph": "^3.8.3",
|
|
47
|
+
"@hpcc-js/layout": "^3.6.3",
|
|
48
|
+
"@hpcc-js/other": "^3.6.3",
|
|
49
|
+
"@hpcc-js/util": "^3.6.3"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@
|
|
52
|
+
"@googlemaps/js-api-loader": "2.1.1",
|
|
53
|
+
"@hpcc-js/esbuild-plugins": "^1.9.3",
|
|
54
|
+
"@types/google.maps": "3.65.1",
|
|
53
55
|
"@types/leaflet-draw": "1.0.13",
|
|
54
56
|
"@types/leaflet.heat": "0.2.5",
|
|
55
57
|
"@types/leaflet.markercluster": "1.5.6",
|
|
@@ -61,7 +63,6 @@
|
|
|
61
63
|
"d3-request": "^1",
|
|
62
64
|
"d3-selection": "^1",
|
|
63
65
|
"d3-tile": "^1",
|
|
64
|
-
"google-maps": "4.3.3",
|
|
65
66
|
"leaflet-draw": "1.0.4",
|
|
66
67
|
"leaflet.heat": "0.2.0",
|
|
67
68
|
"leaflet.markercluster": "1.5.3",
|
|
@@ -79,5 +80,5 @@
|
|
|
79
80
|
"url": "https://github.com/hpcc-systems/Visualization/issues"
|
|
80
81
|
},
|
|
81
82
|
"homepage": "https://github.com/hpcc-systems/Visualization",
|
|
82
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "5ca0d9bcf343ba823fb0c9dc0d9273efb9f5ea83"
|
|
83
84
|
}
|
package/src/GMap.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { HTMLWidget } from "@hpcc-js/common";
|
|
|
2
2
|
import { AbsoluteSurface } from "@hpcc-js/layout";
|
|
3
3
|
import { promiseTimeout } from "@hpcc-js/util";
|
|
4
4
|
import { map as d3Map } from "d3-collection";
|
|
5
|
-
import {
|
|
5
|
+
import { importLibrary, setOptions } from "@googlemaps/js-api-loader";
|
|
6
6
|
|
|
7
7
|
import "../src/GMap.css";
|
|
8
8
|
|
|
@@ -29,9 +29,16 @@ export function requireGoogleMap(customGoogle?: any) {
|
|
|
29
29
|
console.warn("__hpcc_gmap_apikey does not contain a valid API key, reverting to developers key (expect limited performance)");
|
|
30
30
|
}
|
|
31
31
|
try {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
setOptions({
|
|
33
|
+
key: window.__hpcc_gmap_apikey || "AIzaSyDwGn2i1i_pMZvnqYJN1BksD_tjYaCOWKg",
|
|
34
|
+
libraries: ["geometry", "drawing"]
|
|
35
|
+
});
|
|
36
|
+
Promise.all([
|
|
37
|
+
importLibrary("maps"),
|
|
38
|
+
importLibrary("geometry"),
|
|
39
|
+
importLibrary("drawing")
|
|
40
|
+
]).then(function () {
|
|
41
|
+
google = window.google;
|
|
35
42
|
resolve();
|
|
36
43
|
}).catch(function (e) {
|
|
37
44
|
console.warn(`Failed to initialize Google Map API: ${e.message}`);
|
|
@@ -334,6 +341,7 @@ export class GMap extends HTMLWidget {
|
|
|
334
341
|
_circleMap;
|
|
335
342
|
_pinMap;
|
|
336
343
|
_drawingManager;
|
|
344
|
+
_drawingWarningShown;
|
|
337
345
|
_prevCenterAddress;
|
|
338
346
|
_userShapeSelection;
|
|
339
347
|
|
|
@@ -471,17 +479,25 @@ export class GMap extends HTMLWidget {
|
|
|
471
479
|
editable: true,
|
|
472
480
|
clickable: true
|
|
473
481
|
};
|
|
474
|
-
this._drawingManager =
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
482
|
+
this._drawingManager = null;
|
|
483
|
+
this._drawingWarningShown = false;
|
|
484
|
+
if (google?.maps?.drawing?.DrawingManager && google?.maps?.drawing?.OverlayType) {
|
|
485
|
+
try {
|
|
486
|
+
this._drawingManager = new google.maps.drawing.DrawingManager({
|
|
487
|
+
drawingMode: google.maps.drawing.OverlayType.MARKER,
|
|
488
|
+
drawingControl: true,
|
|
489
|
+
drawingControlOptions: {
|
|
490
|
+
position: google.maps.ControlPosition.TOP_CENTER,
|
|
491
|
+
drawingModes: ["polygon", "rectangle", "circle"]
|
|
492
|
+
},
|
|
493
|
+
rectangleOptions: defOptions,
|
|
494
|
+
circleOptions: defOptions,
|
|
495
|
+
polygonOptions: defOptions
|
|
496
|
+
});
|
|
497
|
+
} catch (e) {
|
|
498
|
+
console.warn(`Google DrawingManager unavailable: ${e.message}`);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
485
501
|
|
|
486
502
|
if (this.drawingState()) {
|
|
487
503
|
this._userShapes.load(this.drawingState());
|
|
@@ -546,19 +562,24 @@ export class GMap extends HTMLWidget {
|
|
|
546
562
|
}
|
|
547
563
|
|
|
548
564
|
// Enable or disable drawing tools.
|
|
549
|
-
if (this.
|
|
550
|
-
this.
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
565
|
+
if (this._drawingManager) {
|
|
566
|
+
if (this.drawingTools()) {
|
|
567
|
+
this._drawingManager.setMap(this._googleMap);
|
|
568
|
+
|
|
569
|
+
// Add drawing complete listener to maintain array of drawingState.
|
|
570
|
+
google.maps.event.addListener(
|
|
571
|
+
this._drawingManager,
|
|
572
|
+
"overlaycomplete",
|
|
573
|
+
function () {
|
|
574
|
+
GMap.prototype.onDrawingComplete.apply(context, arguments);
|
|
575
|
+
});
|
|
576
|
+
} else {
|
|
577
|
+
this._drawingManager.setMap(null);
|
|
578
|
+
google.maps.event.clearInstanceListeners(this._drawingManager);
|
|
579
|
+
}
|
|
580
|
+
} else if (this.drawingTools() && !this._drawingWarningShown) {
|
|
581
|
+
this._drawingWarningShown = true;
|
|
582
|
+
console.warn("Google Drawing tools requested, but DrawingManager is unavailable.");
|
|
562
583
|
}
|
|
563
584
|
}
|
|
564
585
|
|
|
@@ -736,7 +757,9 @@ export class GMap extends HTMLWidget {
|
|
|
736
757
|
if (!arguments.length) {
|
|
737
758
|
return this._drawingManager;
|
|
738
759
|
}
|
|
739
|
-
this._drawingManager
|
|
760
|
+
if (this._drawingManager) {
|
|
761
|
+
this._drawingManager.setOptions(_);
|
|
762
|
+
}
|
|
740
763
|
return this;
|
|
741
764
|
}
|
|
742
765
|
|
|
@@ -760,6 +783,9 @@ export class GMap extends HTMLWidget {
|
|
|
760
783
|
}
|
|
761
784
|
|
|
762
785
|
onDrawingComplete(event) {
|
|
786
|
+
if (!this._drawingManager || !google?.maps?.drawing?.OverlayType) {
|
|
787
|
+
return;
|
|
788
|
+
}
|
|
763
789
|
if (event.type !== google.maps.drawing.OverlayType.MARKER) {
|
|
764
790
|
this._drawingManager.setDrawingMode(null);
|
|
765
791
|
const newShape = event.overlay;
|
package/src/leaflet/GMap.ts
CHANGED