From ee73281dd881db5a68d34878377f7a927c5f657f Mon Sep 17 00:00:00 2001 From: Hugh Messenger Date: Sun, 26 Mar 2023 19:52:18 -0500 Subject: [PATCH] Automatically add drawing library if drawing enabled on Map field --- src/Fields/Map.php | 2 +- src/Helpers/MapsHelper.php | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Fields/Map.php b/src/Fields/Map.php index fb08470..2a2a8c2 100644 --- a/src/Fields/Map.php +++ b/src/Fields/Map.php @@ -502,7 +502,7 @@ public function getMapConfig(): string 'reverseGeocodeFields' => $this->getReverseGeocode(), 'defaultZoom' => $this->getDefaultZoom(), 'debug' => $this->getDebug(), - 'gmaps' => MapsHelper::mapsUrl(), + 'gmaps' => MapsHelper::mapsUrl($this->getDrawingControl() ? ['drawing'] : []), ]) ); diff --git a/src/Helpers/MapsHelper.php b/src/Helpers/MapsHelper.php index 8a96c8d..c6a0a37 100644 --- a/src/Helpers/MapsHelper.php +++ b/src/Helpers/MapsHelper.php @@ -31,13 +31,14 @@ public static function mapsRegion($server = false): string|null return config('filament-google-maps.locale.region'); } - public static function mapsUrl($server = false): string + public static function mapsUrl($server = false, array $libraries = []): string { $libraries = implode(',', array_unique( array_filter( array_merge( ['places'], - explode(',', config('filament-google-maps.libraries')) + explode(',', config('filament-google-maps.libraries')), + $libraries ) ) ));