Remove the current location layer if an asset has no location.

This commit is contained in:
paul121 2020-07-02 09:57:43 -07:00 committed by Michael Stenta
parent 19db0bd560
commit 01c7147ddb
2 changed files with 15 additions and 11 deletions

View File

@ -3,7 +3,7 @@
// wkt from the hidden input field and preview it on the map.
Drupal.ajax.prototype.commands.previewCurrentLocation = function() {
var wkt = $('#current-location input[name="move[current_location]"]').val();
if (wkt) {
if (wkt !== 'undefined') {
farmOS.map.behaviors.move.previewCurrentLocation(wkt);
}
}

View File

@ -32,6 +32,9 @@
this.currentLocationLayer = null;
}
// Only add a layer if WKT is not an empty string.
if (wkt.length > 0) {
// Create current location layer with the WKT.
// Do not put the layer inside a group, because map.removeLayer() (used
// above) does not recurse into layer groups.
@ -42,6 +45,7 @@
};
this.currentLocationLayer = this.instance.addLayer('wkt', opts);
this.instance.zoomToVectors();
}
},
// Recreate the Movement map layer.