Skip to content

Commit 967c8bb

Browse files
committed
NuCivic/usda-nal#449: Fix for map widget in data submission form
1 parent a97403e commit 967c8bb

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

js/draw.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,11 @@
9797
write.push(layerToGeometry(layers[key]));
9898
}
9999
}
100-
// Only save if there is a value.
101-
if (write.length) {
102-
$('#' + id + '-input').val(write);
100+
// If no value then provide empty collection.
101+
if (!write.length) {
102+
write = JSON.stringify({"type":"FeatureCollection","features":[]});
103103
}
104+
$('#' + id + '-input').val(write);
104105
}
105106

106107
/**

leaflet_widget.make

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ projects[geophp][subdir] = contrib
1010
libraries[leaflet_draw][type] = libraries
1111
libraries[leaflet_draw][download][type] = git
1212
libraries[leaflet_draw][download][url] = "https://github.com/Leaflet/Leaflet.draw.git"
13-
libraries[leaflet_draw][download][revision] = "82f4d960a44753c3a9d98001e49e03429395b53a"
13+
libraries[leaflet_draw][download][tag] = "v0.2.4"
1414

1515
libraries[leaflet_core][type] = libraries
1616
libraries[leaflet_core][download][type] = git
1717
libraries[leaflet_core][download][url] = "https://github.com/Leaflet/Leaflet.git"
18-
libraries[leaflet_core][download][revision] = "81221ae4cd9772a8974b2e3c867d4fb35abd052d"
18+
libraries[leaflet_core][download][tag] = "v0.7.3"

leaflet_widget.module

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,19 @@ function leaflet_widget_widget_validate($element, &$form_state) {
190190
if (!$geophp) return FALSE;
191191

192192
$geojson = json_decode($element['wkt']['#value']);
193-
194193
$results = array();
195-
if ($geojson->type === 'FeatureCollection') {
196-
foreach ($geojson->features as $feature) {
197-
$results[] = array_merge($results, leaflet_widget_process_geojson($feature));
194+
if ($geojson) {
195+
if ($geojson->type === 'FeatureCollection') {
196+
foreach ($geojson->features as $feature) {
197+
$results[] = array_merge($results, leaflet_widget_process_geojson($feature));
198+
}
199+
}
200+
else {
201+
$results = array(leaflet_widget_process_geojson($geojson));
198202
}
199203
}
200204
else {
201-
$results = array(leaflet_widget_process_geojson($geojson));
205+
$results = array();
202206
}
203207

204208
form_set_value($element, $results, $form_state);
@@ -235,7 +239,7 @@ function leaflet_widget_library() {
235239

236240
$libraries['leaflet_draw'] = array(
237241
'title' => 'Leaflet.draw',
238-
'version' => '2.x',
242+
'version' => '0.2.4',
239243
'css' => array(
240244
"$leaflet_draw/dist/leaflet.draw.css" => array(),
241245
),
@@ -249,13 +253,12 @@ function leaflet_widget_library() {
249253

250254
$libraries['leaflet_core'] = array(
251255
'title' => 'Leaflet (Leaflet Widget)',
252-
'version' => '6',
256+
'version' => '0.7.3',
253257
'css' => array(
254258
"$leaflet_core/dist/leaflet.css" => array(),
255-
"$leaflet_core/dist/leaflet.ie.css" => array('browsers' => array('IE' => 'lte IE 8')),
256259
),
257260
'js' => array(
258-
"$leaflet_core/dist/leaflet-src.js" => array(),
261+
"$leaflet_core/dist/leaflet.js" => array(),
259262
),
260263
);
261264

0 commit comments

Comments
 (0)