Skip to content

Commit

Permalink
Automatically add drawing library if drawing enabled on Map field
Browse files Browse the repository at this point in the history
  • Loading branch information
cheesegrits committed Mar 27, 2023
1 parent febf7f9 commit ee73281
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Fields/Map.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] : []),
])
);

Expand Down
5 changes: 3 additions & 2 deletions src/Helpers/MapsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
)
));
Expand Down

0 comments on commit ee73281

Please sign in to comment.