@longline/aqua-ui 1.0.70 → 1.0.72
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.
|
@@ -51,9 +51,19 @@ interface IProps {
|
|
|
51
51
|
* @default false
|
|
52
52
|
*/
|
|
53
53
|
clickZoom?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Minimum zoom level at which to show markers.
|
|
56
|
+
* @default 0
|
|
57
|
+
*/
|
|
58
|
+
minZoom?: number;
|
|
59
|
+
/**
|
|
60
|
+
* Maximum zoom level at which to show markers.
|
|
61
|
+
* @default 99
|
|
62
|
+
*/
|
|
63
|
+
maxZoom?: number;
|
|
54
64
|
}
|
|
55
65
|
/**
|
|
56
|
-
* A `ClusterLayer` manages its own `Source`. It does not
|
|
66
|
+
* A `ClusterLayer` manages its own `Source`. It does not take GeoJSON, but a list of objects which must at least have
|
|
57
67
|
* `latitude` and `longitude` keys. Other object keys may be used for the aggregate values of clusters; if no field is
|
|
58
68
|
* supplied, then the cluster will display the number of features inside them (the `point_count`).
|
|
59
69
|
*
|
|
@@ -75,5 +85,5 @@ interface IProps {
|
|
|
75
85
|
* </Map>
|
|
76
86
|
* ```
|
|
77
87
|
*/
|
|
78
|
-
declare const ClusterLayer: ({ relativeSize, radius, clusterRadius, clusterMaxZoom, ringFields, clickZoom, ...props }: IProps) => React.JSX.Element;
|
|
88
|
+
declare const ClusterLayer: ({ relativeSize, radius, clusterRadius, clusterMaxZoom, minZoom, maxZoom, ringFields, clickZoom, ...props }: IProps) => React.JSX.Element;
|
|
79
89
|
export { ClusterLayer };
|
|
@@ -78,12 +78,12 @@ var ClusterLayerBase = function (_a) {
|
|
|
78
78
|
});
|
|
79
79
|
};
|
|
80
80
|
return (React.createElement(Source, { id: sourceId, type: 'geojson', data: itemsToFeatures, cluster: true, clusterRadius: clusterRadius, clusterMaxZoom: clusterMaxZoom, clusterProperties: __assign({}, clusterProperties) },
|
|
81
|
-
React.createElement(HtmlMarkerLayer, { sourceId: sourceId, idField: "cluster_id" }, function (markerProps) {
|
|
81
|
+
React.createElement(HtmlMarkerLayer, { sourceId: sourceId, idField: "cluster_id", minZoom: props.minZoom, maxZoom: props.maxZoom }, function (markerProps) {
|
|
82
82
|
return React.createElement(ClusterMarker, __assign({ relativeSize: relativeSize, radius: radius, value: props.aggregation ? markerProps['sum'] : markerProps['point_count'], ringValues: ringFields.map(function (f) { return markerProps[f]; }), onClick: clickZoom ? function () { return handleClick(markerProps.longitude, markerProps.latitude, markerProps.cluster_id); } : null }, markerProps));
|
|
83
83
|
})));
|
|
84
84
|
};
|
|
85
85
|
/**
|
|
86
|
-
* A `ClusterLayer` manages its own `Source`. It does not
|
|
86
|
+
* A `ClusterLayer` manages its own `Source`. It does not take GeoJSON, but a list of objects which must at least have
|
|
87
87
|
* `latitude` and `longitude` keys. Other object keys may be used for the aggregate values of clusters; if no field is
|
|
88
88
|
* supplied, then the cluster will display the number of features inside them (the `point_count`).
|
|
89
89
|
*
|
|
@@ -106,13 +106,13 @@ var ClusterLayerBase = function (_a) {
|
|
|
106
106
|
* ```
|
|
107
107
|
*/
|
|
108
108
|
var ClusterLayer = function (_a) {
|
|
109
|
-
var _b = _a.relativeSize, relativeSize = _b === void 0 ? 0 : _b, _c = _a.radius, radius = _c === void 0 ? 24 : _c, _d = _a.clusterRadius, clusterRadius = _d === void 0 ? 80 : _d, _e = _a.clusterMaxZoom, clusterMaxZoom = _e === void 0 ? 18 : _e, ringFields = _a.ringFields,
|
|
110
|
-
var
|
|
109
|
+
var _b = _a.relativeSize, relativeSize = _b === void 0 ? 0 : _b, _c = _a.radius, radius = _c === void 0 ? 24 : _c, _d = _a.clusterRadius, clusterRadius = _d === void 0 ? 80 : _d, _e = _a.clusterMaxZoom, clusterMaxZoom = _e === void 0 ? 18 : _e, _f = _a.minZoom, minZoom = _f === void 0 ? 0 : _f, _g = _a.maxZoom, maxZoom = _g === void 0 ? 99 : _g, ringFields = _a.ringFields, _h = _a.clickZoom, clickZoom = _h === void 0 ? false : _h, props = __rest(_a, ["relativeSize", "radius", "clusterRadius", "clusterMaxZoom", "minZoom", "maxZoom", "ringFields", "clickZoom"]);
|
|
110
|
+
var _j = React.useState(0), key = _j[0], setKey = _j[1];
|
|
111
111
|
// When aggregation changes, we mount a whole new component. Mapbox does not
|
|
112
112
|
// appear to deal with changes to clusterProperties well.
|
|
113
113
|
React.useEffect(function () {
|
|
114
114
|
setKey(Date.now());
|
|
115
115
|
}, [props.aggregation, ringFields]);
|
|
116
|
-
return React.createElement(ClusterLayerBase, __assign({ key: key, relativeSize: relativeSize, radius: radius, clusterRadius: clusterRadius, clusterMaxZoom: clusterMaxZoom, ringFields: ringFields, clickZoom: clickZoom }, props));
|
|
116
|
+
return React.createElement(ClusterLayerBase, __assign({ key: key, relativeSize: relativeSize, radius: radius, clusterRadius: clusterRadius, clusterMaxZoom: clusterMaxZoom, minZoom: minZoom, maxZoom: maxZoom, ringFields: ringFields, clickZoom: clickZoom }, props));
|
|
117
117
|
};
|
|
118
118
|
export { ClusterLayer };
|
|
@@ -14,7 +14,7 @@ interface IProps {
|
|
|
14
14
|
* Every feature must have a unique ID in its properties. This is used to
|
|
15
15
|
* tell features apart. If the `source` should ever change, then it is
|
|
16
16
|
* important that new items have new IDs, so that old markers get removed
|
|
17
|
-
* correctly.
|
|
17
|
+
* correctly. Features that do not have an ID field are not displayed.
|
|
18
18
|
*/
|
|
19
19
|
idField: string;
|
|
20
20
|
/**
|
|
@@ -44,6 +44,9 @@ import { Marker } from 'mapbox-gl';
|
|
|
44
44
|
* a `props` object, which will be the properties from each GeoJSON feature for which
|
|
45
45
|
* a marker is rendered.
|
|
46
46
|
*
|
|
47
|
+
* The `minZoom` and `maxZoom` properties can be used to make markers appear only
|
|
48
|
+
* within a range of zoom levels.
|
|
49
|
+
*
|
|
47
50
|
* ```tsx
|
|
48
51
|
* // featureCollection has a property "id" with unique values
|
|
49
52
|
* <Source id="mysource" type="geojson" data={featureCollection}>
|
|
@@ -135,8 +138,10 @@ var HtmlMarkerLayerBase = function (props) {
|
|
|
135
138
|
var feature = features_1[_i];
|
|
136
139
|
var coords = feature.geometry.coordinates;
|
|
137
140
|
var fprops = feature.properties;
|
|
138
|
-
// if (!props.cluster) continue;
|
|
139
141
|
var id = fprops[props.idField];
|
|
142
|
+
// Do not render makers without an ID field:
|
|
143
|
+
if (!id)
|
|
144
|
+
continue;
|
|
140
145
|
// Is there a marker for this feature?
|
|
141
146
|
var marker = markers.current[id];
|
|
142
147
|
// If not, create one:
|