Skip to content

Commit

Permalink
run lint and format
Browse files Browse the repository at this point in the history
  • Loading branch information
jokroese committed Jul 19, 2024
1 parent bc52800 commit aec0861
Showing 1 changed file with 40 additions and 35 deletions.
75 changes: 40 additions & 35 deletions src/lib/Map.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -126,44 +126,49 @@
});
addPinLayer(map, activeMarkerLayerId, activeMarkerSourceId, 'add-marker');
map.on('click', markerLayerId, function (e: MapMouseEvent & { features?: MapGeoJSONFeature[] }) { isMomentLayerClicked = true;
if (!e.features || e.features.length === 0) {
return;
}
map.on(
'click',
markerLayerId,
function (e: MapMouseEvent & { features?: MapGeoJSONFeature[] }) {
isMomentLayerClicked = true;
if (!e.features || e.features.length === 0) {
return;
}
const feature = e.features[0];
if (feature.geometry.type !== 'Point') {
return;
}
const feature = e.features[0];
if (feature.geometry.type !== 'Point') {
return;
}
const coordinates = (feature.geometry as Point).coordinates;
if (typeof feature.id !== 'number') {
console.error('Invalid feature id:', feature.id);
return;
}
const coordinates = (feature.geometry as Point).coordinates;
if (typeof feature.id !== 'number') {
console.error('Invalid feature id:', feature.id);
return;
}
getMoment(feature.id)
.then((text) => {
const description = text;
if (coordinates.length === 2) {
new Popup({
offset: {
bottom: [0, -markerHeight]
},
anchor: 'bottom',
maxWidth: 'none'
})
.setLngLat(coordinates as LngLatLike)
.setHTML(description)
.addTo(map);
} else {
console.error('Invalid coordinates format');
}
})
.catch((error) => {
console.error('Error fetching moment:', error);
});
});
getMoment(feature.id)
.then((text) => {
const description = text;
if (coordinates.length === 2) {
new Popup({
offset: {
bottom: [0, -markerHeight]
},
anchor: 'bottom',
maxWidth: 'none'
})
.setLngLat(coordinates as LngLatLike)
.setHTML(description)
.addTo(map);
} else {
console.error('Invalid coordinates format');
}
})
.catch((error) => {
console.error('Error fetching moment:', error);
});
}
);
let hoveredFeatureId: number | null = null;
Expand Down

0 comments on commit aec0861

Please sign in to comment.