Skip to content

Commit

Permalink
fix leaflet typing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
henrinie-nc committed Jul 30, 2024
1 parent 62fe705 commit 3e8a09e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
15 changes: 10 additions & 5 deletions src/areaNote/components/AreaNotesEditMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,16 @@ class AreaNotesEditMap extends Component<Props, State> {

if (!isEmpty(geoJSON)) {
const featuresGeoJSON = new L.GeoJSON(geoJSON);
featuresGeoJSON.eachLayer(layer => {
layer.options.color = SHAPE_COLOR;
layer.options.fillOpacity = SHAPE_FILL_OPACITY;
this.featureGroup?.leafletElement.addLayer(layer);
layer.showMeasurements();
featuresGeoJSON.eachLayer((layer) => {
if (layer instanceof L.Polyline || layer instanceof L.Polygon || layer instanceof L.Circle) {
layer.setStyle({
"color": SHAPE_COLOR,
"fillOpacity": SHAPE_FILL_OPACITY}
);
this.featureGroup?.leafletElement.addLayer(layer);
layer.showMeasurements();
}

});
this.setState({
isValid: true
Expand Down
3 changes: 2 additions & 1 deletion src/util/map.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import isArray from "lodash/isArray";
import type { LatLngBounds } from "leaflet";

/**
* Translate leaflet draw literals in Finnish
Expand Down Expand Up @@ -123,7 +124,7 @@ export const getBoundsFromBBox = (bbox: Array<Record<string, any>>): Record<stri
*/

/* istanbul ignore next */
export const getBoundsFromCoordinates = (coordinates: Array<any>): Record<string, any> => {
export const getBoundsFromCoordinates = (coordinates: Array<any>): LatLngBounds => {
const L = require('leaflet');

const lats = [],
Expand Down

0 comments on commit 3e8a09e

Please sign in to comment.