Skip to content

Commit

Permalink
2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
perliedman committed Sep 7, 2019
1 parent c8bfd48 commit 4a1e9bd
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
25 changes: 19 additions & 6 deletions dist/leaflet-realtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,28 @@ L.Realtime = L.Layer.extend({
getFeatureId: function(f) {
return f.properties.id;
},
updateFeature: function(f, oldLayer) {
updateFeature: function(feature, oldLayer) {
if (!oldLayer) { return; }

if (f.geometry.type === 'Point') {
var c = f.geometry.coordinates;
oldLayer.setLatLng([c[1], c[0]]);
return oldLayer;
var type = feature.geometry && feature.geometry.type
var coordinates = feature.geometry && feature.geometry.coordinates
switch (type) {
case 'Point':
oldLayer.setLatLng(L.GeoJSON.coordsToLatLng(coordinates));
break;
case 'LineString':
case 'MultiLineString':
oldLayer.setLatLngs(L.GeoJSON.coordsToLatLngs(coordinates, type === 'LineString' ? 0 : 1));
break;
case 'Polygon':
case 'MultiPolygon':
oldLayer.setLatLngs(L.GeoJSON.coordsToLatLngs(coordinates, type === 'Polygon' ? 1 : 2));
break;
default:
return null;
}
},
return oldLayer;
},
logErrors: true,
cache: false,
removeMissing: true,
Expand Down
4 changes: 2 additions & 2 deletions dist/leaflet-realtime.min.js

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

2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "leaflet-realtime",
"version": "2.1.4",
"version": "2.2.0",
"description": "Show realtime updated GeoJSON in Leaflet",
"main": "src/L.Realtime.js",
"directories": {
Expand Down

0 comments on commit 4a1e9bd

Please sign in to comment.