Skip to content

Commit

Permalink
Merge pull request #147 from sarapis/feedback-changes
Browse files Browse the repository at this point in the history
Fixed geocode issue
  • Loading branch information
d9it committed Mar 20, 2024
2 parents 9b8d078 + 2639b00 commit 04b8b19
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
20 changes: 10 additions & 10 deletions app/Http/Controllers/frontEnd/ExploreController.php
Expand Up @@ -20,8 +20,6 @@
use App\Model\Source_data;
use App\Model\Taxonomy;
use App\Model\TaxonomyType;
use Geocode;
use Geolocation;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use PDF;
Expand All @@ -40,7 +38,9 @@

class ExploreController extends Controller
{

public function __construct(public Geocoder $geocoder)
{
}
public function geolocation(Request $request)
{
$ip = $request->ip();
Expand Down Expand Up @@ -196,10 +196,11 @@ public function geocode(Request $request)

if ($chip_address != null) {

$response = Geocode::make()->address($chip_address);
$response = $this->geocoder->getCoordinatesForAddress($chip_address);
if ($response) {
$lat = $response->latitude();
$lng = $response->longitude();
$lat = $response['lat'];
$lng = $response['lng'];


$locations = Location::with('services', 'organization')->select(DB::raw('*, ( 3959 * acos( cos( radians(' . $lat . ') ) * cos( radians( location_latitude ) ) * cos( radians( location_longitude ) - radians(' . $lng . ') ) + sin( radians(' . $lat . ') ) * sin( radians( location_latitude ) ) ) ) AS distance'))
->having('distance', '<', 2)
Expand Down Expand Up @@ -362,11 +363,10 @@ public function filter(Request $request)
// $chip_address = 'search near by';
// $chip_service = 'search near by';
} else {
$response = Geocode::make()->address($chip_address);
$response = $this->geocoder->getCoordinatesForAddress($chip_address);
if ($response) {

$lat = $response->latitude();
$lng = $response->longitude();
$lat = $response['lat'];
$lng = $response['lng'];
}
}
// $client = new \GuzzleHttp\Client();
Expand Down
1 change: 0 additions & 1 deletion config/app.php
Expand Up @@ -227,7 +227,6 @@
'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
'Geocode' => Jcf\Geocode\Facades\Geocode::class,
],

];
2 changes: 1 addition & 1 deletion config/geocoder.php
Expand Up @@ -5,7 +5,7 @@
/*
* The api key used when sending Geocoding requests to Google.
*/
'key' => env('GOOGLE_MAPS_GEOCODING_API_KEY', ''),
'key' => env('GEOCODE_GOOGLE_APIKEY', ''),

/*
* The language param used to set response translations for textual data.
Expand Down

0 comments on commit 04b8b19

Please sign in to comment.