Skip to content

Commit

Permalink
Feat: Handle empty tooltips (#317)
Browse files Browse the repository at this point in the history
  • Loading branch information
NiclasNorin authored Aug 23, 2023
1 parent c2c4451 commit 52ad2f4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions source/php/Component/OpenStreetMap/OpenStreetMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ public function init()
foreach ($pins as &$pin) {
$pin['lat'] = strval($pin['lat']);
$pin['lng'] = strval($pin['lng']);

if (isset($pin['tooltip']) && is_array($pin['tooltip'])) {
$pin['tooltip'] = array_filter($pin['tooltip'], function($x) {
if (is_array($x)) {
return !empty(array_filter($x));
}
return !empty($x);
});

if (empty($pin['tooltip'])) {
unset($pin['tooltip']);
}
}
}
$this->data['attributeList']['data-js-map-pin-data'] = json_encode($pins, JSON_UNESCAPED_UNICODE);

Expand Down

0 comments on commit 52ad2f4

Please sign in to comment.