Skip to content

Commit 9dc31ff

Browse files
committed
Add check for properties in GeoJSON objects
1 parent 44df7d1 commit 9dc31ff

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ BUG FIXES and IMPROVEMENTS
55
* Fixed [rstudio/crosstalk#58](https://github.com/rstudio/crosstalk/issues/58), which caused Leaflet maps that used Crosstalk shared data in Shiny apps, to be redrawn at incorrect times.
66
* Upgrade leaflet-provider to 1.4.0, enable more map variants such as CartoDB.Voyager (#567)
77
* `sf` objects with `names` attributes in the `st_geometry` now visualise correctly (#595)
8+
* GeoJSON objects missing `properties` can now be displayed (#622)
89

910

1011

inst/htmlwidgets/leaflet.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1779,7 +1779,7 @@ methods.addGeoJSON = function (data, layerId, group, style) {
17791779
featureId: feature.id,
17801780
properties: feature.properties
17811781
};
1782-
var popup = feature.properties.popup;
1782+
var popup = feature.properties ? feature.properties.popup : null;
17831783
if (typeof popup !== "undefined" && popup !== null) layer.bindPopup(popup);
17841784
layer.on("click", mouseHandler(self.id, layerId, group, "geojson_click", extraInfo), this);
17851785
layer.on("mouseover", mouseHandler(self.id, layerId, group, "geojson_mouseover", extraInfo), this);

javascript/src/methods.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ methods.addGeoJSON = function(data, layerId, group, style) {
591591
featureId: feature.id,
592592
properties: feature.properties
593593
};
594-
let popup = feature.properties.popup;
594+
let popup = feature.properties ? feature.properties.popup : null;
595595
if (typeof popup !== "undefined" && popup !== null) layer.bindPopup(popup);
596596
layer.on("click", mouseHandler(self.id, layerId, group, "geojson_click", extraInfo), this);
597597
layer.on("mouseover", mouseHandler(self.id, layerId, group, "geojson_mouseover", extraInfo), this);

0 commit comments

Comments
 (0)