Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
erkurn authored and github-actions[bot] committed Sep 27, 2022
1 parent 1e0a5d7 commit 6478ffb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion config/filament-address-picker.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php

return [
'google_map_key' => "",
'google_map_key' => '',
];
13 changes: 6 additions & 7 deletions src/Forms/Components/AddressPicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
use Cache\Adapter\PHPArray\ArrayCachePool;
use Filament\Forms\Components\Concerns\HasPlaceholder;
use Filament\Forms\Components\Field;
use Geocoder\Model\AddressCollection;
use Geocoder\Provider\Cache\ProviderCache;
use Geocoder\Provider\GoogleMaps\GoogleMaps;
use Geocoder\Provider\GoogleMaps\Model\GoogleAddress;
use Geocoder\Query\ReverseQuery;
use GuzzleHttp\Client;

Expand All @@ -30,7 +28,7 @@ class AddressPicker extends Field
'streetViewControl' => true,
'rotateControl' => true,
'fullscreenControl' => true,
'searchBoxControl' => false
'searchBoxControl' => false,
];

public array $defaultLocation = [
Expand Down Expand Up @@ -84,24 +82,25 @@ public function getApiKey()
return config('filament-address-picker.google_map_key');
}

public function getAddresses() : \Geocoder\Collection
public function getAddresses(): \Geocoder\Collection
{
$httpClient = new Client();
$provider = new GoogleMaps($httpClient, null, $this->getApiKey());
$cachedProvider = new ProviderCache(
$provider,
new ArrayCachePool(),
60 * 60 * 24
60 * 60 * 24
);

$geocoder = new \Geocoder\StatefulGeocoder($cachedProvider, 'en');

return $geocoder->reverseQuery(ReverseQuery::fromCoordinates(
data_get($this->getState(), 'lat'),
data_get($this->getState(), 'lng')
));
}

public function getAddress() : \Geocoder\Location
public function getAddress(): \Geocoder\Location
{
return $this->getAddresses()->first();
}
Expand All @@ -118,7 +117,7 @@ public function getState()
} catch (\Exception $e) {
return [
'lat' => 0,
'lng' => 0
'lng' => 0,
];
}
}
Expand Down

0 comments on commit 6478ffb

Please sign in to comment.