Skip to content

Commit

Permalink
Merge branch 'main' into feature/drawer+layers
Browse files Browse the repository at this point in the history
  • Loading branch information
PhillipsOwen authored May 2, 2024
2 parents 3ba5c08 + a351bba commit 4937f73
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 11 deletions.
7 changes: 5 additions & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export default [
ecmaFeatures: {
jsx: true,
}},
globals: globals.browser
globals: {
...globals.node,
...globals.browser
}
},
rules: {
"no-unused-vars": "warn",
Expand All @@ -32,4 +35,4 @@ export default [
},
linterOptions: { reportUnusedDisableDirectives: "error" }
}
];
];
9 changes: 6 additions & 3 deletions src/components/map/default-layers.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import React, { useEffect, useState } from 'react';
import { WMSTileLayer, GeoJSON } from 'react-leaflet';
import React, { Fragment, useEffect, useState } from 'react';
import { WMSTileLayer, GeoJSON, useMap } from 'react-leaflet';
import { CircleMarker } from 'leaflet';
import { useLayers } from '@context';
import { markClicked } from '@utils/map-utils';

export const DefaultLayers = () => {

const [obsData, setObsData] = useState("");
const map = useMap();

const {
defaultModelLayers,
Expand Down Expand Up @@ -59,10 +61,11 @@ export const DefaultLayers = () => {
layer.on("mouseout", function () {
this.closePopup();
});
layer.on("click", function () {
layer.on("click", function (e) {
// Do stuff here for retrieving time series data, in csv fomat,
// from the feature.properties.csv_url and create a fancy plot
console.log("Observation Station '" + feature.properties.location_name + "' clicked");
markClicked(map, e);
});
}
};
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 19 additions & 6 deletions src/utils/map-utils.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
import useLayers from '../context/map-context';
import { StacApiProvider } from "stac-react";
//import { useLayers } from '@context';
import locationIcon from '@images/location_searching_FILL0_wght400_GRAD0_opsz24.png';

const {
/* const {
defaultModelLayers,
setDefaultModelLayers,
filteredModelLayers,
setFilteredModelLayers
} = useLayers();
} = useLayers(); */


// Utilities to access the stac catalog items to load on map
const stacCatalog = ({stacUrl}) => {
// function to add a location marker where ever and obs mod layer
// feature is clicked icon downloaded as png from here:
// https://fonts.google.com/icons?selected=Material+Symbols+Outlined:location_searching:FILL@0;wght@400;GRAD@0;opsz@24&icon.query=location
export const markClicked = (map, event) => {

const L = window.L;

const targetIcon = L.icon({
iconUrl: locationIcon,
iconSize: [38, 38],
iconAnchor: [19, 19],
popupAnchor: [0, 0],
});

L.marker([event.latlng.lat, event.latlng.lng], {icon: targetIcon}).addTo(map);
};

0 comments on commit 4937f73

Please sign in to comment.