-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add clusters to inspector panel #283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c513659
112648c
f8e83b7
ac29838
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,48 @@ | ||||||
| import { useInspector } from "@/app/map/[id]/hooks/useInspector"; | ||||||
| import { DataSourceRecordType } from "@/server/models/DataSource"; | ||||||
| import { MarkersList, MembersList } from "./MarkersLists"; | ||||||
| import type { MarkerFeature } from "@/types"; | ||||||
|
|
||||||
| export default function ClusterMarkersList() { | ||||||
| const { selectedRecords, inspectorContent } = useInspector(); | ||||||
| const recordType = inspectorContent?.dataSource?.recordType; | ||||||
| const markerFeatures = selectedRecords | ||||||
| .map((r): MarkerFeature | null => { | ||||||
| if (!r.dataSourceId || !r.geocodePoint) { | ||||||
| // Should never happen for markers in a cluster | ||||||
| return null; | ||||||
| } | ||||||
| return { | ||||||
| type: "Feature", | ||||||
| geometry: { | ||||||
| // [0, 0] should never happen because these records are in a cluster on the map | ||||||
| coordinates: [r.geocodePoint?.lng || 0, r.geocodePoint?.lat || 0], | ||||||
| type: "Point", | ||||||
| }, | ||||||
| properties: { | ||||||
| id: r.id, | ||||||
| name: r.name, | ||||||
| dataSourceId: r.dataSourceId, | ||||||
| matched: true, | ||||||
| }, | ||||||
| }; | ||||||
| }) | ||||||
| .filter((r) => r !== null); | ||||||
|
||||||
| .filter((r) => r !== null); | |
| .filter((r): r is MarkerFeature => r !== null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Records without valid geocodePoints should be filtered out rather than creating markers with coordinates [0, 0]. Consider adding a null check for r.geocodePoint and returning null for records that don't have valid coordinates, or check if both lng and lat exist and are not 0 before creating the feature.