Skip to content
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

leaflet map upgrades #58

Merged
merged 3 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 37 additions & 17 deletions src/components/map/geometry-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ const MetaData = ({
properties: GeoJsonProperties;
layer: Layer;
}) => {
if (properties === null || !properties.name) {
if (properties === null || (!properties.name && !properties.category)) {
return null;
}
return (
<>
<Tooltip>{properties.name}</Tooltip>
{layer.type !== undefined && layer.url && (
<Tooltip>{properties.name ?? properties.category}</Tooltip>
{layer.type !== undefined && layer.url && properties.id && (
<LeafletPopup>
<Popup
name={properties.name}
name={properties.name ?? properties.category}
description={properties.description}
attachments={properties.attachments}
type={layer.type}
Expand Down Expand Up @@ -108,23 +108,42 @@ export const GeometryItem = ({
return (
<>
{coordinatesAsMultiLineString.map((group, index) => {
return (
<Fragment key={`linestring-${id}-${index}`}>
{/* Duplicate streams layer to animate it */}
{layer.type === 'streams' && (
if (layer.type === 'streams') {
return (
<Fragment key={`linestring-${id}-${index}`}>
<Polyline
positions={group.map(([lat, lng]) => [lng, lat])}
pathOptions={options.style as GeoJSONOptions}
className={layer.type}
></Polyline>
{/* Duplicate streams layer to animate it */}
<Polyline
positions={group.map(([lat, lng]) => [lng, lat])}
pathOptions={options.style as GeoJSONOptions}
className="streams-animation"
></Polyline>
)}
<Polyline
positions={group.map(([lat, lng]) => [lng, lat])}
pathOptions={options.style as GeoJSONOptions}
className={layer.type}
>
<MetaData properties={properties} layer={layer} />
</Polyline>
</Fragment>
{/* Add an invisible stream to have a click buffer */}
<Polyline
positions={group.map(([lat, lng]) => [lng, lat])}
pathOptions={{
weight: 10,
opacity: 0,
}}
className={layer.type}
>
<MetaData properties={properties} layer={layer} />
</Polyline>
</Fragment>
);
}
return (
<Polyline
positions={group.map(([lat, lng]) => [lng, lat])}
pathOptions={options.style as GeoJSONOptions}
className={layer.type}
>
<MetaData properties={properties} layer={layer} />
</Polyline>
);
})}
</>
Expand All @@ -145,6 +164,7 @@ export const GeometryItem = ({
line.map<[number, number]>(([lat, lng]) => [lng, lat]),
)}
pathOptions={options.style as GeoJSONOptions}
pane="tilePane"
>
<MetaData properties={properties} layer={layer} />
</Polygon>
Expand Down
2 changes: 1 addition & 1 deletion src/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ body .leaflet-container a.leaflet-popup-close-button {
vertical-align: middle !important;
}

.streams.leaflet-interactive {
.streams-animation.leaflet-interactive {
stroke-width: 2;
stroke: rgba(255, 255, 255, 0.6);
stroke-dasharray: 10;
Expand Down
Loading