@@ -16,7 +16,7 @@ public static function mapsSigningKey(): ?string
1616 {
1717 return config ('filament-google-maps.keys.signing_key ' , null );
1818 }
19-
19+
2020 public static function hasSigningKey (): bool
2121 {
2222 return !empty (self ::mapsSigningKey ());
@@ -34,24 +34,31 @@ public static function mapsRegion($server = false): string|null
3434
3535 public static function mapsUrl ($ server = false ): string
3636 {
37+ $ libraries = implode (', ' , array_unique (
38+ array_filter (
39+ array_merge (
40+ ['places ' ],
41+ explode (', ' , config ('filament-google-maps.libraries ' ))
42+ )
43+ )
44+ ));
45+
3746 $ gmaps = (Request::getScheme () ?? 'https ' ) . '://maps.googleapis.com/maps/api/js '
3847 . '?key= ' . self ::mapsKey ($ server )
39- . '&libraries=places '
48+ . '&libraries= ' . $ libraries
4049 . '&v=weekly ' ;
4150
4251 /**
4352 * https://developers.google.com/maps/faq#languagesupport
4453 */
45- if ($ server && $ language = self ::mapsLanguage ())
46- {
54+ if ($ server && $ language = self ::mapsLanguage ()) {
4755 $ gmaps .= '&language= ' . $ language ;
4856 }
4957
5058 /**
5159 * https://developers.google.com/maps/coverage
5260 */
53- if ($ region = self ::mapsRegion ())
54- {
61+ if ($ region = self ::mapsRegion ()) {
5562 $ gmaps .= '®ion= ' . $ region ;
5663 }
5764
@@ -73,8 +80,7 @@ public static function getCountyFromAddress(string $address): string
7380 $ geocoder = new Geocoder ();
7481 $ result = $ geocoder ->geocodeQuery ($ address )->first ();
7582
76- if ($ result )
77- {
83+ if ($ result ) {
7884 return $ geocoder ->formatter ->format ($ result , '%A2 ' );
7985 }
8086
@@ -86,8 +92,7 @@ public static function getCountyFromLatLng(array|string $lat, ?string $lng = nul
8692 $ geocoder = new Geocoder ();
8793 $ result = $ geocoder ->reverseQuery (self ::getLatLng ($ lat , $ lng ))->first ();
8894
89- if ($ result )
90- {
95+ if ($ result ) {
9196 return $ geocoder ->formatter ->format ($ result , '%A2 ' );
9297 }
9398
@@ -96,22 +101,18 @@ public static function getCountyFromLatLng(array|string $lat, ?string $lng = nul
96101
97102 public static function getLatLng (array |string $ lat , ?string $ lng = null ): array
98103 {
99- if (is_array ($ lat ))
100- {
101- if (array_key_exists ('lat ' , $ lat ) && array_key_exists ('lng ' , $ lat ))
102- {
104+ if (is_array ($ lat )) {
105+ if (array_key_exists ('lat ' , $ lat ) && array_key_exists ('lng ' , $ lat )) {
103106 return $ lat ;
104107 }
105- else if (count ($ lat ) === 2 )
106- {
108+ else if (count ($ lat ) === 2 ) {
107109 return [
108110 'lat ' => $ lat [0 ],
109111 'lng ' => $ lat [1 ],
110112 ];
111113 }
112114 }
113- else if (isset ($ lng ))
114- {
115+ else if (isset ($ lng )) {
115116 return [
116117 'lat ' => $ lat ,
117118 'lng ' => $ lng ,
@@ -123,21 +124,18 @@ public static function getLatLng(array|string $lat, ?string $lng = null): array
123124
124125 public static function isLocationEmpty ($ location ): bool
125126 {
126- if (empty ($ location ))
127- {
127+ if (empty ($ location )) {
128128 return true ;
129129 }
130130
131- if (array_key_exists ('lat ' , $ location ) && array_key_exists ('lng ' , $ location ))
132- {
131+ if (array_key_exists ('lat ' , $ location ) && array_key_exists ('lng ' , $ location )) {
133132 return empty ($ location ['lat ' ]) && empty ($ location ['lng ' ]);
134133 }
135134
136- if (is_array ($ location ) && is_numeric ($ location [0 ] && is_numeric ($ location [1 ])))
137- {
135+ if (is_array ($ location ) && is_numeric ($ location [0 ] && is_numeric ($ location [1 ]))) {
138136 return empty ($ location [0 ] && empty ($ location [1 ]));
139137 }
140138
141139 return true ;
142140 }
143- }
141+ }
0 commit comments