react-map4d-map 1.0.2 → 1.0.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.
@@ -762,6 +762,7 @@ var MFMap = /*#__PURE__*/function (_React$Component) {
762
762
  var _this;
763
763
 
764
764
  _this = _React$Component.call(this, props) || this;
765
+ _this.events = [];
765
766
  _this.state = {
766
767
  map: null
767
768
  };
@@ -782,7 +783,7 @@ var MFMap = /*#__PURE__*/function (_React$Component) {
782
783
  };
783
784
 
784
785
  _proto.destroy = function destroy() {
785
- var _this$eventClickMarke, _this$eventRightClick, _this$eventDragEndMar, _this$mapRef;
786
+ var _this$events, _this$mapRef;
786
787
 
787
788
  delete window[this.callback];
788
789
 
@@ -790,55 +791,103 @@ var MFMap = /*#__PURE__*/function (_React$Component) {
790
791
  this.scriptElement.remove();
791
792
  }
792
793
 
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();
794
+ (_this$events = this.events) === null || _this$events === void 0 ? void 0 : _this$events.forEach(function (t) {
795
+ t === null || t === void 0 ? void 0 : t.remove();
796
+ });
796
797
  ((_this$mapRef = this.mapRef) === null || _this$mapRef === void 0 ? void 0 : _this$mapRef.destroy) && this.mapRef.destroy();
797
798
  this.url = null;
798
799
  };
799
800
 
800
801
  _proto.registerEvent = function registerEvent() {
801
- var _this$mapRef2, _this$mapRef3, _this$mapRef4;
802
+ var _this$mapRef2,
803
+ _this$mapRef3,
804
+ _this$mapRef4,
805
+ _this2 = this;
802
806
 
803
- this.eventClickMarker = (_this$mapRef2 = this.mapRef) === null || _this$mapRef2 === void 0 ? void 0 : _this$mapRef2.addListener("click", function (args) {
807
+ var eventClickMarker = (_this$mapRef2 = this.mapRef) === null || _this$mapRef2 === void 0 ? void 0 : _this$mapRef2.addListener("click", function (args) {
804
808
  var _args$marker, _args$marker2;
805
809
 
806
810
  ((_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
811
  }, {
808
812
  marker: true
809
813
  });
810
- this.eventRightClickMarker = (_this$mapRef3 = this.mapRef) === null || _this$mapRef3 === void 0 ? void 0 : _this$mapRef3.addListener("rightClick", function (args) {
814
+ var eventRightClickMarker = (_this$mapRef3 = this.mapRef) === null || _this$mapRef3 === void 0 ? void 0 : _this$mapRef3.addListener("rightClick", function (args) {
811
815
  var _args$marker3, _args$marker4;
812
816
 
813
817
  ((_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
818
  }, {
815
819
  marker: true
816
820
  });
817
- this.eventDragEndMarker = (_this$mapRef4 = this.mapRef) === null || _this$mapRef4 === void 0 ? void 0 : _this$mapRef4.addListener("dragEnd", function (args) {
821
+ var eventDragEndMarker = (_this$mapRef4 = this.mapRef) === null || _this$mapRef4 === void 0 ? void 0 : _this$mapRef4.addListener("dragEnd", function (args) {
818
822
  var _args$marker5, _args$marker6;
819
823
 
820
824
  ((_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
825
  }, {
822
826
  marker: true
823
827
  });
828
+ this.events.push([eventClickMarker, eventRightClickMarker, eventDragEndMarker]);
829
+
830
+ if (this.props.onClickLocation) {
831
+ var _this$mapRef5;
832
+
833
+ var onClickLocation = (_this$mapRef5 = this.mapRef) === null || _this$mapRef5 === void 0 ? void 0 : _this$mapRef5.addListener("click", function (args) {
834
+ _this2.props.onClickLocation && _this2.props.onClickLocation(args);
835
+ }, {
836
+ location: true
837
+ });
838
+ this.events.push(onClickLocation);
839
+ }
840
+
841
+ if (this.props.onRightClickLocation) {
842
+ var _this$mapRef6;
843
+
844
+ var onRightClickLocation = (_this$mapRef6 = this.mapRef) === null || _this$mapRef6 === void 0 ? void 0 : _this$mapRef6.addListener("rightClick", function (args) {
845
+ _this2.props.onRightClickLocation && _this2.props.onRightClickLocation(args);
846
+ }, {
847
+ location: true
848
+ });
849
+ this.events.push(onRightClickLocation);
850
+ }
851
+
852
+ if (this.props.onTilesLoaded) {
853
+ var _this$mapRef7;
854
+
855
+ var onTilesLoaded = (_this$mapRef7 = this.mapRef) === null || _this$mapRef7 === void 0 ? void 0 : _this$mapRef7.addListener("tilesLoaded", function (args) {
856
+ _this2.props.onTilesLoaded && _this2.props.onTilesLoaded(args);
857
+ }, {
858
+ location: true
859
+ });
860
+ this.events.push(onTilesLoaded);
861
+ }
862
+
863
+ if (this.props.onCameraChanging) {
864
+ var _this$mapRef8;
865
+
866
+ var onCameraChanging = (_this$mapRef8 = this.mapRef) === null || _this$mapRef8 === void 0 ? void 0 : _this$mapRef8.addListener("cameraChanging", function (args) {
867
+ _this2.props.onCameraChanging && _this2.props.onCameraChanging(args);
868
+ }, {
869
+ location: true
870
+ });
871
+ this.events.push(onCameraChanging);
872
+ }
824
873
  };
825
874
 
826
875
  _proto.createCallback = function createCallback() {
827
- var _this2 = this;
876
+ var _this3 = this;
828
877
 
829
878
  window[this.callback] = function () {
830
- if (_this2.mapDomRef) {
831
- var options = _this2.props.options;
832
- _this2.mapRef = new window.map4d.Map(_this2.mapDomRef, options);
879
+ if (_this3.mapDomRef) {
880
+ var options = _this3.props.options;
881
+ _this3.mapRef = new window.map4d.Map(_this3.mapDomRef, options);
833
882
 
834
- if (_this2.props.onMapReady) {
835
- _this2.props.onMapReady(_this2.mapRef, _this2.mapKey);
883
+ if (_this3.props.onMapReady) {
884
+ _this3.props.onMapReady(_this3.mapRef, _this3.mapKey);
836
885
  }
837
886
 
838
- _this2.registerEvent();
887
+ _this3.registerEvent();
839
888
 
840
- _this2.setState({
841
- map: _this2.mapRef
889
+ _this3.setState({
890
+ map: _this3.mapRef
842
891
  });
843
892
  } else {
844
893
  console.error("MFMap: map element is NOT found");