Skip to content

Commit

Permalink
Merge pull request #2 from NuCivic/nal_449
Browse files Browse the repository at this point in the history
Fix for map widget in data submission form
  • Loading branch information
teosibileau committed Jun 2, 2015
2 parents a97403e + 967c8bb commit c3f388f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
7 changes: 4 additions & 3 deletions js/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,11 @@
write.push(layerToGeometry(layers[key]));
}
}
// Only save if there is a value.
if (write.length) {
$('#' + id + '-input').val(write);
// If no value then provide empty collection.
if (!write.length) {
write = JSON.stringify({"type":"FeatureCollection","features":[]});
}
$('#' + id + '-input').val(write);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions leaflet_widget.make
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ projects[geophp][subdir] = contrib
libraries[leaflet_draw][type] = libraries
libraries[leaflet_draw][download][type] = git
libraries[leaflet_draw][download][url] = "https://github.com/Leaflet/Leaflet.draw.git"
libraries[leaflet_draw][download][revision] = "82f4d960a44753c3a9d98001e49e03429395b53a"
libraries[leaflet_draw][download][tag] = "v0.2.4"

libraries[leaflet_core][type] = libraries
libraries[leaflet_core][download][type] = git
libraries[leaflet_core][download][url] = "https://github.com/Leaflet/Leaflet.git"
libraries[leaflet_core][download][revision] = "81221ae4cd9772a8974b2e3c867d4fb35abd052d"
libraries[leaflet_core][download][tag] = "v0.7.3"
21 changes: 12 additions & 9 deletions leaflet_widget.module
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,19 @@ function leaflet_widget_widget_validate($element, &$form_state) {
if (!$geophp) return FALSE;

$geojson = json_decode($element['wkt']['#value']);

$results = array();
if ($geojson->type === 'FeatureCollection') {
foreach ($geojson->features as $feature) {
$results[] = array_merge($results, leaflet_widget_process_geojson($feature));
if ($geojson) {
if ($geojson->type === 'FeatureCollection') {
foreach ($geojson->features as $feature) {
$results[] = array_merge($results, leaflet_widget_process_geojson($feature));
}
}
else {
$results = array(leaflet_widget_process_geojson($geojson));
}
}
else {
$results = array(leaflet_widget_process_geojson($geojson));
$results = array();
}

form_set_value($element, $results, $form_state);
Expand Down Expand Up @@ -235,7 +239,7 @@ function leaflet_widget_library() {

$libraries['leaflet_draw'] = array(
'title' => 'Leaflet.draw',
'version' => '2.x',
'version' => '0.2.4',
'css' => array(
"$leaflet_draw/dist/leaflet.draw.css" => array(),
),
Expand All @@ -249,13 +253,12 @@ function leaflet_widget_library() {

$libraries['leaflet_core'] = array(
'title' => 'Leaflet (Leaflet Widget)',
'version' => '6',
'version' => '0.7.3',
'css' => array(
"$leaflet_core/dist/leaflet.css" => array(),
"$leaflet_core/dist/leaflet.ie.css" => array('browsers' => array('IE' => 'lte IE 8')),
),
'js' => array(
"$leaflet_core/dist/leaflet-src.js" => array(),
"$leaflet_core/dist/leaflet.js" => array(),
),
);

Expand Down

0 comments on commit c3f388f

Please sign in to comment.