diff --git a/modules/farm/farm_livestock/js/farm_livestock.farm_quick.move.js b/modules/farm/farm_livestock/js/farm_livestock.farm_quick.move.js index 005bdd606..04dc88783 100644 --- a/modules/farm/farm_livestock/js/farm_livestock.farm_quick.move.js +++ b/modules/farm/farm_livestock/js/farm_livestock.farm_quick.move.js @@ -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); } } diff --git a/modules/farm/farm_movement/js/farmOS.map.behaviors.move.js b/modules/farm/farm_movement/js/farmOS.map.behaviors.move.js index 587570166..0c043a19d 100644 --- a/modules/farm/farm_movement/js/farmOS.map.behaviors.move.js +++ b/modules/farm/farm_movement/js/farmOS.map.behaviors.move.js @@ -32,16 +32,20 @@ this.currentLocationLayer = null; } - // 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. - var opts = { - title: 'Current Location', - color: 'blue', - wkt: wkt, - }; - this.currentLocationLayer = this.instance.addLayer('wkt', opts); - this.instance.zoomToVectors(); + // 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. + var opts = { + title: 'Current Location', + color: 'blue', + wkt: wkt, + }; + this.currentLocationLayer = this.instance.addLayer('wkt', opts); + this.instance.zoomToVectors(); + } }, // Recreate the Movement map layer.