Skip to content

Commit

Permalink
Allow unlocated features
Browse files Browse the repository at this point in the history
  • Loading branch information
piranna committed Sep 4, 2024
1 parent 7817a7e commit 5462e73
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dist/Leaflet.GeoSSE.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions src/Leaflet.GeoSSE.src.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,22 @@ const GeoSSE = L.GeoJSON.extend({
// Layer not found, add it
if (!layer) return self.addData(feature);

// Check for feature type mismatch
const {geometry} = layer.feature;
const {type} = feature.geometry;

// Check if the feature is unlocated
if(geometry === null)
return console.warn("Feature is unlocated.", feature);

const {coordinates: [lng, lat], type} = feature.geometry;

// Check for feature type mismatch
if(geometry.type !== type)
console.warn(
`Feature type mismatch: existing feature type is ${geometry.type} ` +
`and new feature type is ${type}.`, feature
);

// Update the position of the Marker
const {coordinates: [lng, lat]} = feature.geometry;
layer.setLatLng({lat, lng});

// Re-init the layer
Expand Down

0 comments on commit 5462e73

Please sign in to comment.