react-map4d-map 1.0.2 → 1.0.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/components/MFMap.d.ts +23 -5
- package/dist/components/MFMarker.d.ts +1 -1
- package/dist/enum/mapEventEnum.d.ts +3 -1
- package/dist/index.js +66 -17
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +66 -17
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,12 +1,32 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export declare function addLibrary(url: string, id: string): HTMLScriptElement | null;
|
|
3
|
+
interface MapOptions {
|
|
4
|
+
center?: any;
|
|
5
|
+
zoom?: number;
|
|
6
|
+
minZoom?: number;
|
|
7
|
+
maxZoom?: number;
|
|
8
|
+
maxNativeZoom?: number;
|
|
9
|
+
geolocate?: boolean;
|
|
10
|
+
tilt?: number;
|
|
11
|
+
bearing?: number;
|
|
12
|
+
controls?: boolean;
|
|
13
|
+
mapType?: any;
|
|
14
|
+
controlOptions?: any;
|
|
15
|
+
restrictionBounds?: any;
|
|
16
|
+
shouldChangeMapMode?: Function;
|
|
17
|
+
cooperativeGestures?: boolean;
|
|
18
|
+
}
|
|
3
19
|
interface MapProps {
|
|
4
20
|
mapid?: string;
|
|
5
|
-
options:
|
|
21
|
+
options: MapOptions;
|
|
6
22
|
version: string;
|
|
7
23
|
accessKey: string;
|
|
8
24
|
environment?: "dev" | "test" | undefined | null;
|
|
9
|
-
onMapReady: (map:
|
|
25
|
+
onMapReady: (map: any, key?: string) => void;
|
|
26
|
+
onClickLocation?: (args: any) => void;
|
|
27
|
+
onRightClickLocation?: (args: any) => void;
|
|
28
|
+
onCameraChanging?: (args: any) => void;
|
|
29
|
+
onTilesLoaded?: (args: any) => void;
|
|
10
30
|
}
|
|
11
31
|
declare class MFMap extends React.Component<MapProps, any> {
|
|
12
32
|
mapKey: string;
|
|
@@ -15,9 +35,7 @@ declare class MFMap extends React.Component<MapProps, any> {
|
|
|
15
35
|
mapRef: map4d.Map;
|
|
16
36
|
scriptElement: any;
|
|
17
37
|
url: string | null;
|
|
18
|
-
|
|
19
|
-
eventRightClickMarker: any;
|
|
20
|
-
eventDragEndMarker: any;
|
|
38
|
+
events: any[];
|
|
21
39
|
constructor(props: MapProps);
|
|
22
40
|
setMapDomRef(e: any): void;
|
|
23
41
|
componentWillUnmount(): void;
|
|
@@ -14,7 +14,7 @@ interface MarkerProps extends map4d.MarkerOptions {
|
|
|
14
14
|
draggable?: boolean;
|
|
15
15
|
iconView?: string | Node;
|
|
16
16
|
userInteractionEnabled?: boolean;
|
|
17
|
-
map?:
|
|
17
|
+
map?: any;
|
|
18
18
|
onClick: (marker: any) => void;
|
|
19
19
|
onCreated: (marker: any) => void;
|
|
20
20
|
onRightClick: (marker: any) => void;
|
package/dist/index.js
CHANGED
|
@@ -765,6 +765,7 @@ var MFMap = /*#__PURE__*/function (_React$Component) {
|
|
|
765
765
|
var _this;
|
|
766
766
|
|
|
767
767
|
_this = _React$Component.call(this, props) || this;
|
|
768
|
+
_this.events = [];
|
|
768
769
|
_this.state = {
|
|
769
770
|
map: null
|
|
770
771
|
};
|
|
@@ -785,7 +786,7 @@ var MFMap = /*#__PURE__*/function (_React$Component) {
|
|
|
785
786
|
};
|
|
786
787
|
|
|
787
788
|
_proto.destroy = function destroy() {
|
|
788
|
-
var _this$
|
|
789
|
+
var _this$events, _this$mapRef;
|
|
789
790
|
|
|
790
791
|
delete window[this.callback];
|
|
791
792
|
|
|
@@ -793,55 +794,103 @@ var MFMap = /*#__PURE__*/function (_React$Component) {
|
|
|
793
794
|
this.scriptElement.remove();
|
|
794
795
|
}
|
|
795
796
|
|
|
796
|
-
(_this$
|
|
797
|
-
|
|
798
|
-
|
|
797
|
+
(_this$events = this.events) === null || _this$events === void 0 ? void 0 : _this$events.forEach(function (t) {
|
|
798
|
+
t === null || t === void 0 ? void 0 : t.remove();
|
|
799
|
+
});
|
|
799
800
|
((_this$mapRef = this.mapRef) === null || _this$mapRef === void 0 ? void 0 : _this$mapRef.destroy) && this.mapRef.destroy();
|
|
800
801
|
this.url = null;
|
|
801
802
|
};
|
|
802
803
|
|
|
803
804
|
_proto.registerEvent = function registerEvent() {
|
|
804
|
-
var _this$mapRef2,
|
|
805
|
+
var _this$mapRef2,
|
|
806
|
+
_this$mapRef3,
|
|
807
|
+
_this$mapRef4,
|
|
808
|
+
_this2 = this;
|
|
805
809
|
|
|
806
|
-
|
|
810
|
+
var eventClickMarker = (_this$mapRef2 = this.mapRef) === null || _this$mapRef2 === void 0 ? void 0 : _this$mapRef2.addListener("click", function (args) {
|
|
807
811
|
var _args$marker, _args$marker2;
|
|
808
812
|
|
|
809
813
|
((_args$marker = args.marker) === null || _args$marker === void 0 ? void 0 : _args$marker.onClick) && ((_args$marker2 = args.marker) === null || _args$marker2 === void 0 ? void 0 : _args$marker2.onClick());
|
|
810
814
|
}, {
|
|
811
815
|
marker: true
|
|
812
816
|
});
|
|
813
|
-
|
|
817
|
+
var eventRightClickMarker = (_this$mapRef3 = this.mapRef) === null || _this$mapRef3 === void 0 ? void 0 : _this$mapRef3.addListener("rightClick", function (args) {
|
|
814
818
|
var _args$marker3, _args$marker4;
|
|
815
819
|
|
|
816
820
|
((_args$marker3 = args.marker) === null || _args$marker3 === void 0 ? void 0 : _args$marker3.onRightClick) && ((_args$marker4 = args.marker) === null || _args$marker4 === void 0 ? void 0 : _args$marker4.onRightClick());
|
|
817
821
|
}, {
|
|
818
822
|
marker: true
|
|
819
823
|
});
|
|
820
|
-
|
|
824
|
+
var eventDragEndMarker = (_this$mapRef4 = this.mapRef) === null || _this$mapRef4 === void 0 ? void 0 : _this$mapRef4.addListener("dragEnd", function (args) {
|
|
821
825
|
var _args$marker5, _args$marker6;
|
|
822
826
|
|
|
823
827
|
((_args$marker5 = args.marker) === null || _args$marker5 === void 0 ? void 0 : _args$marker5.onDragEnd) && ((_args$marker6 = args.marker) === null || _args$marker6 === void 0 ? void 0 : _args$marker6.onDragEnd());
|
|
824
828
|
}, {
|
|
825
829
|
marker: true
|
|
826
830
|
});
|
|
831
|
+
this.events.push([eventClickMarker, eventRightClickMarker, eventDragEndMarker]);
|
|
832
|
+
|
|
833
|
+
if (this.props.onClickLocation) {
|
|
834
|
+
var _this$mapRef5;
|
|
835
|
+
|
|
836
|
+
var onClickLocation = (_this$mapRef5 = this.mapRef) === null || _this$mapRef5 === void 0 ? void 0 : _this$mapRef5.addListener("click", function (args) {
|
|
837
|
+
_this2.props.onClickLocation && _this2.props.onClickLocation(args);
|
|
838
|
+
}, {
|
|
839
|
+
location: true
|
|
840
|
+
});
|
|
841
|
+
this.events.push(onClickLocation);
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
if (this.props.onRightClickLocation) {
|
|
845
|
+
var _this$mapRef6;
|
|
846
|
+
|
|
847
|
+
var onRightClickLocation = (_this$mapRef6 = this.mapRef) === null || _this$mapRef6 === void 0 ? void 0 : _this$mapRef6.addListener("rightClick", function (args) {
|
|
848
|
+
_this2.props.onRightClickLocation && _this2.props.onRightClickLocation(args);
|
|
849
|
+
}, {
|
|
850
|
+
location: true
|
|
851
|
+
});
|
|
852
|
+
this.events.push(onRightClickLocation);
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
if (this.props.onTilesLoaded) {
|
|
856
|
+
var _this$mapRef7;
|
|
857
|
+
|
|
858
|
+
var onTilesLoaded = (_this$mapRef7 = this.mapRef) === null || _this$mapRef7 === void 0 ? void 0 : _this$mapRef7.addListener("tilesLoaded", function (args) {
|
|
859
|
+
_this2.props.onTilesLoaded && _this2.props.onTilesLoaded(args);
|
|
860
|
+
}, {
|
|
861
|
+
location: true
|
|
862
|
+
});
|
|
863
|
+
this.events.push(onTilesLoaded);
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
if (this.props.onCameraChanging) {
|
|
867
|
+
var _this$mapRef8;
|
|
868
|
+
|
|
869
|
+
var onCameraChanging = (_this$mapRef8 = this.mapRef) === null || _this$mapRef8 === void 0 ? void 0 : _this$mapRef8.addListener("cameraChanging", function (args) {
|
|
870
|
+
_this2.props.onCameraChanging && _this2.props.onCameraChanging(args);
|
|
871
|
+
}, {
|
|
872
|
+
location: true
|
|
873
|
+
});
|
|
874
|
+
this.events.push(onCameraChanging);
|
|
875
|
+
}
|
|
827
876
|
};
|
|
828
877
|
|
|
829
878
|
_proto.createCallback = function createCallback() {
|
|
830
|
-
var
|
|
879
|
+
var _this3 = this;
|
|
831
880
|
|
|
832
881
|
window[this.callback] = function () {
|
|
833
|
-
if (
|
|
834
|
-
var options =
|
|
835
|
-
|
|
882
|
+
if (_this3.mapDomRef) {
|
|
883
|
+
var options = _this3.props.options;
|
|
884
|
+
_this3.mapRef = new window.map4d.Map(_this3.mapDomRef, options);
|
|
836
885
|
|
|
837
|
-
if (
|
|
838
|
-
|
|
886
|
+
if (_this3.props.onMapReady) {
|
|
887
|
+
_this3.props.onMapReady(_this3.mapRef, _this3.mapKey);
|
|
839
888
|
}
|
|
840
889
|
|
|
841
|
-
|
|
890
|
+
_this3.registerEvent();
|
|
842
891
|
|
|
843
|
-
|
|
844
|
-
map:
|
|
892
|
+
_this3.setState({
|
|
893
|
+
map: _this3.mapRef
|
|
845
894
|
});
|
|
846
895
|
} else {
|
|
847
896
|
console.error("MFMap: map element is NOT found");
|