react-map4d-map 1.3.6 → 1.3.8

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.
@@ -12,6 +12,7 @@ interface PolygonProps {
12
12
  map?: map4d.Map;
13
13
  onCreated?: (polygon: map4d.Polygon) => void;
14
14
  onHover?: (args: any) => void;
15
+ onClick?: (args: any) => void;
15
16
  }
16
17
  declare const MFPolygon: (props: PolygonProps) => null;
17
18
  export default MFPolygon;
package/dist/index.js CHANGED
@@ -1013,11 +1013,13 @@ var MFMap = function MFMap(props) {
1013
1013
  poi: true
1014
1014
  });
1015
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;
1016
+ var _args$circle, _args$circle2, _args$polygon3, _args$polygon3$onClic;
1017
1017
 
1018
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);
1019
1020
  }, {
1020
- circle: true
1021
+ circle: true,
1022
+ polygon: true
1021
1023
  })]);
1022
1024
 
1023
1025
  if (props.onClickLocation) {
@@ -1357,7 +1359,7 @@ var MFMarkerCluster = function MFMarkerCluster(props) {
1357
1359
  (_markerClusterRef$cur = markerClusterRef.current) === null || _markerClusterRef$cur === void 0 ? void 0 : _markerClusterRef$cur.setMap(null);
1358
1360
 
1359
1361
  if (theMap) {
1360
- var _markerClusterRef$cur2;
1362
+ var _markerRefs$current;
1361
1363
 
1362
1364
  var option = {
1363
1365
  minZoom: minZoom,
@@ -1370,9 +1372,14 @@ var MFMarkerCluster = function MFMarkerCluster(props) {
1370
1372
  delete option[key];
1371
1373
  }
1372
1374
  });
1373
- markerClusterRef.current = new map4d.MarkerClusterer(markerRefs.current, option);
1374
- (_markerClusterRef$cur2 = markerClusterRef.current) === null || _markerClusterRef$cur2 === void 0 ? void 0 : _markerClusterRef$cur2.setMap(theMap);
1375
- onCreated && onCreated(markerClusterRef.current);
1375
+
1376
+ if (markerRefs.current && ((_markerRefs$current = markerRefs.current) === null || _markerRefs$current === void 0 ? void 0 : _markerRefs$current.length) > 0) {
1377
+ var _markerClusterRef$cur2;
1378
+
1379
+ markerClusterRef.current = new map4d.MarkerClusterer(markerRefs.current, option);
1380
+ (_markerClusterRef$cur2 = markerClusterRef.current) === null || _markerClusterRef$cur2 === void 0 ? void 0 : _markerClusterRef$cur2.setMap(theMap);
1381
+ onCreated && onCreated(markerClusterRef.current);
1382
+ }
1376
1383
  }
1377
1384
  };
1378
1385
 
@@ -1650,6 +1657,7 @@ var MFPolygon = function MFPolygon(props) {
1650
1657
  userInteractionEnabled = props.userInteractionEnabled,
1651
1658
  map = props.map,
1652
1659
  onHover = props.onHover,
1660
+ onClick = props.onClick,
1653
1661
  onCreated = props.onCreated;
1654
1662
  var map4dContext = React.useContext(Map4dContext);
1655
1663
  var theMap = map || map4dContext.map;
@@ -1678,6 +1686,7 @@ var MFPolygon = function MFPolygon(props) {
1678
1686
  polygonRef.current = new map4d.Polygon(option);
1679
1687
  (_polygonRef$current = polygonRef.current) === null || _polygonRef$current === void 0 ? void 0 : _polygonRef$current.setMap(theMap);
1680
1688
  polygonRef.current.onHover = props.onHover;
1689
+ polygonRef.current.onClick = onClick;
1681
1690
  onCreated && onCreated(polygonRef.current);
1682
1691
  }
1683
1692
  }, [theMap]);
@@ -1706,6 +1715,11 @@ var MFPolygon = function MFPolygon(props) {
1706
1715
  polygonRef.current.onHover = onHover;
1707
1716
  }
1708
1717
  }, [onHover]);
1718
+ React.useEffect(function () {
1719
+ if (polygonRef.current) {
1720
+ polygonRef.current.onClick = onClick;
1721
+ }
1722
+ }, [onClick]);
1709
1723
  React.useEffect(function () {
1710
1724
  var _polygonRef$current5;
1711
1725