diff --git a/www/map.html b/www/map.html
index a5127e0..4c48f0e 100644
--- a/www/map.html
+++ b/www/map.html
@@ -236,7 +236,9 @@
}).done(function (data) {
lines.addData(data);
var id = data.features[0].properties.id;
- lines.getLayer(linesArray[id]["leafletId"]).openPopup();
+ if (map.hasLayer(lines)) {
+ lines.getLayer(linesArray[id]["leafletId"]).openPopup();
+ }
var bounds = lines.getLayer(linesArray[id]["leafletId"]).getBounds();
map.flyToBounds(bounds);
});