react-map4d-map 1.3.5 → 1.3.7
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/MFCircle.d.ts +1 -0
- package/dist/components/MFMap.d.ts +4 -0
- package/dist/components/MFPolygon.d.ts +1 -0
- package/dist/index.js +77 -20
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +77 -20
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
|
@@ -19,6 +19,10 @@ interface MapOptions {
|
|
|
19
19
|
interface MapProps {
|
|
20
20
|
mapid?: string;
|
|
21
21
|
options: MapOptions;
|
|
22
|
+
zoom?: number;
|
|
23
|
+
bearing?: number;
|
|
24
|
+
center?: any;
|
|
25
|
+
tilt?: number;
|
|
22
26
|
version: string;
|
|
23
27
|
accessKey: string;
|
|
24
28
|
environment?: "dev" | "test" | undefined | null;
|
package/dist/index.js
CHANGED
|
@@ -252,7 +252,8 @@ var MFCircle = function MFCircle(props) {
|
|
|
252
252
|
elevation = props.elevation,
|
|
253
253
|
userInteractionEnabled = props.userInteractionEnabled,
|
|
254
254
|
map = props.map,
|
|
255
|
-
onCreated = props.onCreated
|
|
255
|
+
onCreated = props.onCreated,
|
|
256
|
+
onClick = props.onClick;
|
|
256
257
|
var map4dContext = React.useContext(Map4dContext);
|
|
257
258
|
var theMap = map || map4dContext.map;
|
|
258
259
|
var circleRef = React.useRef();
|
|
@@ -284,8 +285,14 @@ var MFCircle = function MFCircle(props) {
|
|
|
284
285
|
circleRef.current = new map4d.Circle(option);
|
|
285
286
|
(_circleRef$current = circleRef.current) === null || _circleRef$current === void 0 ? void 0 : _circleRef$current.setMap(theMap);
|
|
286
287
|
onCreated && onCreated(circleRef.current);
|
|
288
|
+
circleRef.current.onClick = onClick;
|
|
287
289
|
}
|
|
288
290
|
}, [theMap]);
|
|
291
|
+
React.useEffect(function () {
|
|
292
|
+
if (circleRef.current) {
|
|
293
|
+
circleRef.current.onClick = onClick;
|
|
294
|
+
}
|
|
295
|
+
}, [onClick]);
|
|
289
296
|
React.useEffect(function () {
|
|
290
297
|
if (theMap) {
|
|
291
298
|
var _circleRef$current2;
|
|
@@ -764,25 +771,60 @@ var createId = function createId() {
|
|
|
764
771
|
};
|
|
765
772
|
|
|
766
773
|
var MFMap = function MFMap(props) {
|
|
774
|
+
var _options = React.useRef({
|
|
775
|
+
options: props.options,
|
|
776
|
+
mapId: props.mapid,
|
|
777
|
+
version: props.version,
|
|
778
|
+
environment: props.environment,
|
|
779
|
+
accessKey: props.accessKey,
|
|
780
|
+
sdkDomain: props.sdkDomain
|
|
781
|
+
});
|
|
782
|
+
|
|
767
783
|
var callback = React.useRef("callback");
|
|
768
784
|
var mapDomRef = React.useRef();
|
|
769
785
|
var mapRef = React.useRef();
|
|
770
786
|
var scriptElement = React.useRef();
|
|
771
787
|
var url = React.useRef();
|
|
772
788
|
var events = React.useRef([]);
|
|
789
|
+
var zoom = props.zoom,
|
|
790
|
+
bearing = props.bearing,
|
|
791
|
+
center = props.center,
|
|
792
|
+
tilt = props.tilt;
|
|
773
793
|
|
|
774
794
|
var _useState = React.useState(),
|
|
775
795
|
map = _useState[0],
|
|
776
796
|
setMap = _useState[1];
|
|
777
797
|
|
|
798
|
+
React.useEffect(function () {
|
|
799
|
+
if (map) {
|
|
800
|
+
var camera = map.getCamera();
|
|
801
|
+
|
|
802
|
+
if (zoom != undefined && zoom != null) {
|
|
803
|
+
camera.setZoom(zoom);
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
if (bearing != undefined && bearing != null) {
|
|
807
|
+
camera.setBearing(bearing);
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
if (center != undefined && center != null) {
|
|
811
|
+
camera.setTarget(center);
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
if (tilt != undefined && tilt != null) {
|
|
815
|
+
camera.setTilt(center);
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
map.moveCamera(camera);
|
|
819
|
+
}
|
|
820
|
+
}, [zoom, bearing, center, map]);
|
|
778
821
|
React.useEffect(function () {
|
|
779
822
|
var id = createId();
|
|
780
823
|
callback.current = "callback_" + id;
|
|
781
824
|
|
|
782
825
|
var createCallback = function createCallback() {
|
|
783
826
|
window[callback.current] = function () {
|
|
784
|
-
|
|
785
|
-
mapRef.current = new window.map4d.Map(mapDomRef.current, options);
|
|
827
|
+
mapRef.current = new window.map4d.Map(mapDomRef.current, _options.current.options);
|
|
786
828
|
|
|
787
829
|
if (props.onMapReady) {
|
|
788
830
|
props.onMapReady(mapRef.current, id);
|
|
@@ -793,16 +835,16 @@ var MFMap = function MFMap(props) {
|
|
|
793
835
|
};
|
|
794
836
|
};
|
|
795
837
|
|
|
796
|
-
var domain = "https://api" + (props.environment ? "-" +
|
|
838
|
+
var domain = "https://api" + (props.environment ? "-" + _options.current.environment : "") + ".map4d.vn";
|
|
797
839
|
|
|
798
|
-
if (
|
|
799
|
-
domain =
|
|
840
|
+
if (_options.current.sdkDomain) {
|
|
841
|
+
domain = _options.current.sdkDomain;
|
|
800
842
|
}
|
|
801
843
|
|
|
802
|
-
var urlNew = domain + "/sdk/map/js?version=" +
|
|
844
|
+
var urlNew = domain + "/sdk/map/js?version=" + _options.current.version + "&key=" + _options.current.accessKey + "&callback=" + callback.current;
|
|
803
845
|
|
|
804
|
-
if (
|
|
805
|
-
urlNew += "&mapId=" +
|
|
846
|
+
if (_options.current.mapId) {
|
|
847
|
+
urlNew += "&mapId=" + _options.current.mapId;
|
|
806
848
|
}
|
|
807
849
|
|
|
808
850
|
createCallback();
|
|
@@ -832,10 +874,10 @@ var MFMap = function MFMap(props) {
|
|
|
832
874
|
|
|
833
875
|
destroy();
|
|
834
876
|
};
|
|
835
|
-
}, [
|
|
877
|
+
}, []);
|
|
836
878
|
|
|
837
879
|
var registerEvent = function registerEvent() {
|
|
838
|
-
var _mapRef$current2, _mapRef$current3, _mapRef$current4, _mapRef$current5, _mapRef$current6, _mapRef$current7, _mapRef$current8, _mapRef$current9, _mapRef$current10, _mapRef$current11, _mapRef$current12, _mapRef$current13, _mapRef$current14, _mapRef$current15, _mapRef$current16, _mapRef$current17, _mapRef$current18, _mapRef$current19, _mapRef$current20;
|
|
880
|
+
var _mapRef$current2, _mapRef$current3, _mapRef$current4, _mapRef$current5, _mapRef$current6, _mapRef$current7, _mapRef$current8, _mapRef$current9, _mapRef$current10, _mapRef$current11, _mapRef$current12, _mapRef$current13, _mapRef$current14, _mapRef$current15, _mapRef$current16, _mapRef$current17, _mapRef$current18, _mapRef$current19, _mapRef$current20, _mapRef$current21;
|
|
839
881
|
|
|
840
882
|
var eventClickMarker = (_mapRef$current2 = mapRef.current) === null || _mapRef$current2 === void 0 ? void 0 : _mapRef$current2.addListener("click", function (args) {
|
|
841
883
|
var _args$marker, _args$marker2;
|
|
@@ -970,12 +1012,20 @@ var MFMap = function MFMap(props) {
|
|
|
970
1012
|
}, {
|
|
971
1013
|
poi: true
|
|
972
1014
|
});
|
|
973
|
-
events.current = events.current.concat([eventClickMarker, eventRightClickMarker, eventDragEndMarker, eventHoverMarker, eventHoverPolygon, eventHoverPolyline, eventHoverDirection, eventClickPolyline, eventMouseOutDirection, eventMouseOverDirection, eventMouseMoveDirection, eventMouseOutPolyline, eventMouseOverPolyline, eventMouseMovePolyline, eventMouseOutMarker, eventMouseOverMarker, eventMouseMoveMarker, eventClickPoi, eventHoverPoi
|
|
1015
|
+
events.current = events.current.concat([eventClickMarker, eventRightClickMarker, eventDragEndMarker, eventHoverMarker, eventHoverPolygon, eventHoverPolyline, eventHoverDirection, eventClickPolyline, eventMouseOutDirection, eventMouseOverDirection, eventMouseMoveDirection, eventMouseOutPolyline, eventMouseOverPolyline, eventMouseMovePolyline, eventMouseOutMarker, eventMouseOverMarker, eventMouseMoveMarker, eventClickPoi, eventHoverPoi, (_mapRef$current21 = mapRef.current) === null || _mapRef$current21 === void 0 ? void 0 : _mapRef$current21.addListener("click", function (args) {
|
|
1016
|
+
var _args$circle, _args$circle2, _args$polygon3, _args$polygon3$onClic;
|
|
1017
|
+
|
|
1018
|
+
((_args$circle = args.circle) === null || _args$circle === void 0 ? void 0 : _args$circle.onClick) && ((_args$circle2 = args.circle) === null || _args$circle2 === void 0 ? void 0 : _args$circle2.onClick(args));
|
|
1019
|
+
(_args$polygon3 = args.polygon) === null || _args$polygon3 === void 0 ? void 0 : (_args$polygon3$onClic = _args$polygon3.onClick) === null || _args$polygon3$onClic === void 0 ? void 0 : _args$polygon3$onClic.call(_args$polygon3, args);
|
|
1020
|
+
}, {
|
|
1021
|
+
circle: true,
|
|
1022
|
+
polygon: true
|
|
1023
|
+
})]);
|
|
974
1024
|
|
|
975
1025
|
if (props.onClickLocation) {
|
|
976
|
-
var _mapRef$
|
|
1026
|
+
var _mapRef$current22;
|
|
977
1027
|
|
|
978
|
-
var onClickLocation = (_mapRef$
|
|
1028
|
+
var onClickLocation = (_mapRef$current22 = mapRef.current) === null || _mapRef$current22 === void 0 ? void 0 : _mapRef$current22.addListener("click", function (args) {
|
|
979
1029
|
props.onClickLocation && props.onClickLocation(args);
|
|
980
1030
|
}, {
|
|
981
1031
|
location: true
|
|
@@ -984,9 +1034,9 @@ var MFMap = function MFMap(props) {
|
|
|
984
1034
|
}
|
|
985
1035
|
|
|
986
1036
|
if (props.onRightClickLocation) {
|
|
987
|
-
var _mapRef$
|
|
1037
|
+
var _mapRef$current23;
|
|
988
1038
|
|
|
989
|
-
var onRightClickLocation = (_mapRef$
|
|
1039
|
+
var onRightClickLocation = (_mapRef$current23 = mapRef.current) === null || _mapRef$current23 === void 0 ? void 0 : _mapRef$current23.addListener("rightClick", function (args) {
|
|
990
1040
|
props.onRightClickLocation && props.onRightClickLocation(args);
|
|
991
1041
|
}, {
|
|
992
1042
|
location: true
|
|
@@ -995,9 +1045,9 @@ var MFMap = function MFMap(props) {
|
|
|
995
1045
|
}
|
|
996
1046
|
|
|
997
1047
|
if (props.onTilesLoaded) {
|
|
998
|
-
var _mapRef$
|
|
1048
|
+
var _mapRef$current24;
|
|
999
1049
|
|
|
1000
|
-
var onTilesLoaded = (_mapRef$
|
|
1050
|
+
var onTilesLoaded = (_mapRef$current24 = mapRef.current) === null || _mapRef$current24 === void 0 ? void 0 : _mapRef$current24.addListener("tilesLoaded", function (args) {
|
|
1001
1051
|
props.onTilesLoaded && props.onTilesLoaded(args);
|
|
1002
1052
|
}, {
|
|
1003
1053
|
location: true
|
|
@@ -1006,9 +1056,9 @@ var MFMap = function MFMap(props) {
|
|
|
1006
1056
|
}
|
|
1007
1057
|
|
|
1008
1058
|
if (props.onCameraChanging) {
|
|
1009
|
-
var _mapRef$
|
|
1059
|
+
var _mapRef$current25;
|
|
1010
1060
|
|
|
1011
|
-
var onCameraChanging = (_mapRef$
|
|
1061
|
+
var onCameraChanging = (_mapRef$current25 = mapRef.current) === null || _mapRef$current25 === void 0 ? void 0 : _mapRef$current25.addListener("cameraChanging", function (args) {
|
|
1012
1062
|
props.onCameraChanging && props.onCameraChanging(args);
|
|
1013
1063
|
}, {
|
|
1014
1064
|
location: true
|
|
@@ -1602,6 +1652,7 @@ var MFPolygon = function MFPolygon(props) {
|
|
|
1602
1652
|
userInteractionEnabled = props.userInteractionEnabled,
|
|
1603
1653
|
map = props.map,
|
|
1604
1654
|
onHover = props.onHover,
|
|
1655
|
+
onClick = props.onClick,
|
|
1605
1656
|
onCreated = props.onCreated;
|
|
1606
1657
|
var map4dContext = React.useContext(Map4dContext);
|
|
1607
1658
|
var theMap = map || map4dContext.map;
|
|
@@ -1630,6 +1681,7 @@ var MFPolygon = function MFPolygon(props) {
|
|
|
1630
1681
|
polygonRef.current = new map4d.Polygon(option);
|
|
1631
1682
|
(_polygonRef$current = polygonRef.current) === null || _polygonRef$current === void 0 ? void 0 : _polygonRef$current.setMap(theMap);
|
|
1632
1683
|
polygonRef.current.onHover = props.onHover;
|
|
1684
|
+
polygonRef.current.onClick = onClick;
|
|
1633
1685
|
onCreated && onCreated(polygonRef.current);
|
|
1634
1686
|
}
|
|
1635
1687
|
}, [theMap]);
|
|
@@ -1658,6 +1710,11 @@ var MFPolygon = function MFPolygon(props) {
|
|
|
1658
1710
|
polygonRef.current.onHover = onHover;
|
|
1659
1711
|
}
|
|
1660
1712
|
}, [onHover]);
|
|
1713
|
+
React.useEffect(function () {
|
|
1714
|
+
if (polygonRef.current) {
|
|
1715
|
+
polygonRef.current.onClick = onClick;
|
|
1716
|
+
}
|
|
1717
|
+
}, [onClick]);
|
|
1661
1718
|
React.useEffect(function () {
|
|
1662
1719
|
var _polygonRef$current5;
|
|
1663
1720
|
|