react-map4d-map 1.0.1 → 1.0.2

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.
@@ -706,23 +706,6 @@ var MFImageOverlay = function MFImageOverlay(props) {
706
706
  return null;
707
707
  };
708
708
 
709
- function _extends() {
710
- _extends = Object.assign ? Object.assign.bind() : function (target) {
711
- for (var i = 1; i < arguments.length; i++) {
712
- var source = arguments[i];
713
-
714
- for (var key in source) {
715
- if (Object.prototype.hasOwnProperty.call(source, key)) {
716
- target[key] = source[key];
717
- }
718
- }
719
- }
720
-
721
- return target;
722
- };
723
- return _extends.apply(this, arguments);
724
- }
725
-
726
709
  function _inheritsLoose(subClass, superClass) {
727
710
  subClass.prototype = Object.create(superClass.prototype);
728
711
  subClass.prototype.constructor = subClass;
@@ -799,7 +782,7 @@ var MFMap = /*#__PURE__*/function (_React$Component) {
799
782
  };
800
783
 
801
784
  _proto.destroy = function destroy() {
802
- var _this$mapRef;
785
+ var _this$eventClickMarke, _this$eventRightClick, _this$eventDragEndMar, _this$mapRef;
803
786
 
804
787
  delete window[this.callback];
805
788
 
@@ -807,10 +790,39 @@ var MFMap = /*#__PURE__*/function (_React$Component) {
807
790
  this.scriptElement.remove();
808
791
  }
809
792
 
793
+ (_this$eventClickMarke = this.eventClickMarker) === null || _this$eventClickMarke === void 0 ? void 0 : _this$eventClickMarke.remove();
794
+ (_this$eventRightClick = this.eventRightClickMarker) === null || _this$eventRightClick === void 0 ? void 0 : _this$eventRightClick.remove();
795
+ (_this$eventDragEndMar = this.eventDragEndMarker) === null || _this$eventDragEndMar === void 0 ? void 0 : _this$eventDragEndMar.remove();
810
796
  ((_this$mapRef = this.mapRef) === null || _this$mapRef === void 0 ? void 0 : _this$mapRef.destroy) && this.mapRef.destroy();
811
797
  this.url = null;
812
798
  };
813
799
 
800
+ _proto.registerEvent = function registerEvent() {
801
+ var _this$mapRef2, _this$mapRef3, _this$mapRef4;
802
+
803
+ this.eventClickMarker = (_this$mapRef2 = this.mapRef) === null || _this$mapRef2 === void 0 ? void 0 : _this$mapRef2.addListener("click", function (args) {
804
+ var _args$marker, _args$marker2;
805
+
806
+ ((_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());
807
+ }, {
808
+ marker: true
809
+ });
810
+ this.eventRightClickMarker = (_this$mapRef3 = this.mapRef) === null || _this$mapRef3 === void 0 ? void 0 : _this$mapRef3.addListener("rightClick", function (args) {
811
+ var _args$marker3, _args$marker4;
812
+
813
+ ((_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());
814
+ }, {
815
+ marker: true
816
+ });
817
+ this.eventDragEndMarker = (_this$mapRef4 = this.mapRef) === null || _this$mapRef4 === void 0 ? void 0 : _this$mapRef4.addListener("dragEnd", function (args) {
818
+ var _args$marker5, _args$marker6;
819
+
820
+ ((_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());
821
+ }, {
822
+ marker: true
823
+ });
824
+ };
825
+
814
826
  _proto.createCallback = function createCallback() {
815
827
  var _this2 = this;
816
828
 
@@ -823,6 +835,8 @@ var MFMap = /*#__PURE__*/function (_React$Component) {
823
835
  _this2.props.onMapReady(_this2.mapRef, _this2.mapKey);
824
836
  }
825
837
 
838
+ _this2.registerEvent();
839
+
826
840
  _this2.setState({
827
841
  map: _this2.mapRef
828
842
  });
@@ -850,10 +864,9 @@ var MFMap = /*#__PURE__*/function (_React$Component) {
850
864
  }
851
865
 
852
866
  this.url = url;
853
-
854
- var newContext = _extends({}, this.context);
855
-
856
- newContext.map = this.state.map;
867
+ var newContext = {
868
+ map: this.state.map
869
+ };
857
870
  return React.createElement(Map4dContext.Provider, {
858
871
  value: newContext
859
872
  }, React.createElement("div", {
@@ -890,7 +903,8 @@ var MFMarker = function MFMarker(props) {
890
903
  iconView = props.iconView,
891
904
  userInteractionEnabled = props.userInteractionEnabled,
892
905
  map = props.map,
893
- onCreated = props.onCreated;
906
+ onCreated = props.onCreated,
907
+ onClick = props.onClick;
894
908
  var map4dContext = useContext(Map4dContext);
895
909
  var markerClusterContext = useContext(MarkerClusterContext);
896
910
  var theMap = map || map4dContext.map;
@@ -925,11 +939,12 @@ var MFMarker = function MFMarker(props) {
925
939
  markerRef.current = new map4d.Marker(option);
926
940
 
927
941
  if (!(markerClusterContext !== null && markerClusterContext !== void 0 && markerClusterContext.addMarker)) {
928
- var _markerRef$current;
929
-
930
- (_markerRef$current = markerRef.current) === null || _markerRef$current === void 0 ? void 0 : _markerRef$current.setMap(theMap);
942
+ markerRef.current.setMap(theMap);
931
943
  }
932
944
 
945
+ markerRef.current.onClick = onClick;
946
+ markerRef.current.onRightClick = props.onRightClick;
947
+ markerRef.current.onDragEnd = props.onDragEnd;
933
948
  onCreated && onCreated(markerRef.current);
934
949
  (markerClusterContext === null || markerClusterContext === void 0 ? void 0 : markerClusterContext.addMarker) && (markerClusterContext === null || markerClusterContext === void 0 ? void 0 : markerClusterContext.addMarker(markerRef.current));
935
950
  }
@@ -937,105 +952,105 @@ var MFMarker = function MFMarker(props) {
937
952
  useEffect(function () {
938
953
  if (theMap) {
939
954
  if (!(markerClusterContext !== null && markerClusterContext !== void 0 && markerClusterContext.addMarker)) {
940
- var _markerRef$current2;
955
+ var _markerRef$current;
941
956
 
942
- (_markerRef$current2 = markerRef.current) === null || _markerRef$current2 === void 0 ? void 0 : _markerRef$current2.setMap(theMap);
957
+ (_markerRef$current = markerRef.current) === null || _markerRef$current === void 0 ? void 0 : _markerRef$current.setMap(theMap);
943
958
  }
944
959
  }
945
960
 
946
961
  return function () {
947
962
  if (!(markerClusterContext !== null && markerClusterContext !== void 0 && markerClusterContext.addMarker)) {
948
- var _markerRef$current3;
963
+ var _markerRef$current2;
949
964
 
950
- (_markerRef$current3 = markerRef.current) === null || _markerRef$current3 === void 0 ? void 0 : _markerRef$current3.setMap(null);
965
+ (_markerRef$current2 = markerRef.current) === null || _markerRef$current2 === void 0 ? void 0 : _markerRef$current2.setMap(null);
951
966
  }
952
967
  };
953
968
  }, [theMap]);
954
969
  useEffect(function () {
955
970
  return function () {
956
971
  if (!(markerClusterContext !== null && markerClusterContext !== void 0 && markerClusterContext.addMarker)) {
957
- var _markerRef$current4;
972
+ var _markerRef$current3;
958
973
 
959
- (_markerRef$current4 = markerRef.current) === null || _markerRef$current4 === void 0 ? void 0 : _markerRef$current4.setMap(null);
974
+ (_markerRef$current3 = markerRef.current) === null || _markerRef$current3 === void 0 ? void 0 : _markerRef$current3.setMap(null);
960
975
  }
961
976
 
962
977
  markerRef.current && (markerClusterContext === null || markerClusterContext === void 0 ? void 0 : markerClusterContext.removeMarker) && (markerClusterContext === null || markerClusterContext === void 0 ? void 0 : markerClusterContext.removeMarker(markerRef.current));
963
978
  };
964
979
  }, []);
965
980
  useEffect(function () {
966
- var _markerRef$current5;
981
+ var _markerRef$current4;
967
982
 
968
- (_markerRef$current5 = markerRef.current) === null || _markerRef$current5 === void 0 ? void 0 : _markerRef$current5.setPosition(position);
983
+ (_markerRef$current4 = markerRef.current) === null || _markerRef$current4 === void 0 ? void 0 : _markerRef$current4.setPosition(position);
969
984
  }, [position]);
970
985
  useEffect(function () {
971
- var _markerRef$current6;
986
+ var _markerRef$current5;
972
987
 
973
- (_markerRef$current6 = markerRef.current) === null || _markerRef$current6 === void 0 ? void 0 : _markerRef$current6.setVisible(visible);
988
+ (_markerRef$current5 = markerRef.current) === null || _markerRef$current5 === void 0 ? void 0 : _markerRef$current5.setVisible(visible);
974
989
  }, [visible]);
975
990
  useEffect(function () {
976
- var _markerRef$current7;
991
+ var _markerRef$current6;
977
992
 
978
- anchor != undefined && ((_markerRef$current7 = markerRef.current) === null || _markerRef$current7 === void 0 ? void 0 : _markerRef$current7.setAnchor(anchor));
993
+ anchor != undefined && ((_markerRef$current6 = markerRef.current) === null || _markerRef$current6 === void 0 ? void 0 : _markerRef$current6.setAnchor(anchor));
979
994
  }, [anchor]);
980
995
  useEffect(function () {
981
- var _markerRef$current8;
996
+ var _markerRef$current7;
982
997
 
983
- labelAnchor != undefined && ((_markerRef$current8 = markerRef.current) === null || _markerRef$current8 === void 0 ? void 0 : _markerRef$current8.setLabelAnchor(labelAnchor));
998
+ labelAnchor != undefined && ((_markerRef$current7 = markerRef.current) === null || _markerRef$current7 === void 0 ? void 0 : _markerRef$current7.setLabelAnchor(labelAnchor));
984
999
  }, [labelAnchor]);
985
1000
  useEffect(function () {
986
- var _markerRef$current9;
1001
+ var _markerRef$current8;
987
1002
 
988
- icon != undefined && ((_markerRef$current9 = markerRef.current) === null || _markerRef$current9 === void 0 ? void 0 : _markerRef$current9.setIcon(icon));
1003
+ icon != undefined && ((_markerRef$current8 = markerRef.current) === null || _markerRef$current8 === void 0 ? void 0 : _markerRef$current8.setIcon(icon));
989
1004
  }, [icon]);
990
1005
  useEffect(function () {
991
- var _markerRef$current10;
1006
+ var _markerRef$current9;
992
1007
 
993
- elevation != undefined && ((_markerRef$current10 = markerRef.current) === null || _markerRef$current10 === void 0 ? void 0 : _markerRef$current10.setElevation(elevation));
1008
+ elevation != undefined && ((_markerRef$current9 = markerRef.current) === null || _markerRef$current9 === void 0 ? void 0 : _markerRef$current9.setElevation(elevation));
994
1009
  }, [elevation]);
995
1010
  useEffect(function () {
996
- var _markerRef$current11;
1011
+ var _markerRef$current10;
997
1012
 
998
- rotation != undefined && ((_markerRef$current11 = markerRef.current) === null || _markerRef$current11 === void 0 ? void 0 : _markerRef$current11.setRotation(rotation));
1013
+ rotation != undefined && ((_markerRef$current10 = markerRef.current) === null || _markerRef$current10 === void 0 ? void 0 : _markerRef$current10.setRotation(rotation));
999
1014
  }, [rotation]);
1000
1015
  useEffect(function () {
1001
- var _markerRef$current12;
1016
+ var _markerRef$current11;
1002
1017
 
1003
- title != undefined && ((_markerRef$current12 = markerRef.current) === null || _markerRef$current12 === void 0 ? void 0 : _markerRef$current12.setTitle(title));
1018
+ title != undefined && ((_markerRef$current11 = markerRef.current) === null || _markerRef$current11 === void 0 ? void 0 : _markerRef$current11.setTitle(title));
1004
1019
  }, [title]);
1005
1020
  useEffect(function () {
1006
- var _markerRef$current13;
1021
+ var _markerRef$current12;
1007
1022
 
1008
- snippet != undefined && ((_markerRef$current13 = markerRef.current) === null || _markerRef$current13 === void 0 ? void 0 : _markerRef$current13.setSnippet(snippet));
1023
+ snippet != undefined && ((_markerRef$current12 = markerRef.current) === null || _markerRef$current12 === void 0 ? void 0 : _markerRef$current12.setSnippet(snippet));
1009
1024
  }, [snippet]);
1010
1025
  useEffect(function () {
1011
- var _markerRef$current14;
1026
+ var _markerRef$current13;
1012
1027
 
1013
- windowAnchor != undefined && ((_markerRef$current14 = markerRef.current) === null || _markerRef$current14 === void 0 ? void 0 : _markerRef$current14.setWindowAnchor(windowAnchor));
1028
+ windowAnchor != undefined && ((_markerRef$current13 = markerRef.current) === null || _markerRef$current13 === void 0 ? void 0 : _markerRef$current13.setWindowAnchor(windowAnchor));
1014
1029
  }, [windowAnchor]);
1015
1030
  useEffect(function () {
1016
- var _markerRef$current15;
1031
+ var _markerRef$current14;
1017
1032
 
1018
- zIndex != undefined && ((_markerRef$current15 = markerRef.current) === null || _markerRef$current15 === void 0 ? void 0 : _markerRef$current15.setZIndex(zIndex));
1033
+ zIndex != undefined && ((_markerRef$current14 = markerRef.current) === null || _markerRef$current14 === void 0 ? void 0 : _markerRef$current14.setZIndex(zIndex));
1019
1034
  }, [zIndex]);
1020
1035
  useEffect(function () {
1021
- var _markerRef$current16;
1036
+ var _markerRef$current15;
1022
1037
 
1023
- label != undefined && ((_markerRef$current16 = markerRef.current) === null || _markerRef$current16 === void 0 ? void 0 : _markerRef$current16.setLabel(label));
1038
+ label != undefined && ((_markerRef$current15 = markerRef.current) === null || _markerRef$current15 === void 0 ? void 0 : _markerRef$current15.setLabel(label));
1024
1039
  }, [label]);
1025
1040
  useEffect(function () {
1026
- var _markerRef$current17;
1041
+ var _markerRef$current16;
1027
1042
 
1028
- draggable != undefined && ((_markerRef$current17 = markerRef.current) === null || _markerRef$current17 === void 0 ? void 0 : _markerRef$current17.setDraggable(draggable));
1043
+ draggable != undefined && ((_markerRef$current16 = markerRef.current) === null || _markerRef$current16 === void 0 ? void 0 : _markerRef$current16.setDraggable(draggable));
1029
1044
  }, [draggable]);
1030
1045
  useEffect(function () {
1031
- var _markerRef$current18;
1046
+ var _markerRef$current17;
1032
1047
 
1033
- iconView != undefined && ((_markerRef$current18 = markerRef.current) === null || _markerRef$current18 === void 0 ? void 0 : _markerRef$current18.setIconView(iconView));
1048
+ iconView != undefined && ((_markerRef$current17 = markerRef.current) === null || _markerRef$current17 === void 0 ? void 0 : _markerRef$current17.setIconView(iconView));
1034
1049
  }, [iconView]);
1035
1050
  useEffect(function () {
1036
- var _markerRef$current19;
1051
+ var _markerRef$current18;
1037
1052
 
1038
- userInteractionEnabled != undefined && ((_markerRef$current19 = markerRef.current) === null || _markerRef$current19 === void 0 ? void 0 : _markerRef$current19.setUserInteraction(userInteractionEnabled));
1053
+ userInteractionEnabled != undefined && ((_markerRef$current18 = markerRef.current) === null || _markerRef$current18 === void 0 ? void 0 : _markerRef$current18.setUserInteraction(userInteractionEnabled));
1039
1054
  }, [userInteractionEnabled]);
1040
1055
  return null;
1041
1056
  };