Skip to content

Commit

Permalink
Merge pull request #58 from Georiviere/map_fixes
Browse files Browse the repository at this point in the history
leaflet map upgrades
  • Loading branch information
Bo-Duke authored Apr 8, 2024
2 parents 1263535 + ec53859 commit f758718
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 18 deletions.
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

0 comments on commit f758718

Please sign in to comment.