Closed StanBarrows closed 7 years ago
What version of Mac are you on?
hi Mike, I’m on Sierra and the newest Version of Laravel Valet. I’m try the code on my webserver later this day.
Yea, Sierra has/had? a problem with OpenSSL, so it didn't complete the request. If you run it in Homestead it should work (and of course on your server as well). This works fine under High Sierra, I would recommend upgrading if you have no other issues with High Sierra.
@mikebronner
hey, mike. I tried the same on my web server. But unfortunately with the same results. Just an empty collection.
GeoCode Method - Image Code
Geocoder::geocode('Los Angeles, CA')->get();
Same results with the reverse method.
$result = Geocoder::reverse(43.882587,-103.454067)->get();
Maybe i'm missing something out of the configuration. What I'm doing atm:
Cheers, Stan
What is your server OS and version?
@mikebronner - Its an Ubuntu 16.04.1 LTS
@mikebronner Maybe i'm missing out something else, because when i remove the API KEY in the env file i'm getting the same result.
What I'm doing atm:
Did you follow step 5 in the 0.x to 1.0 upgrade notes? Try using app('geocoder')
instead of the facade. I believe the facade was removed a while back.
Hi Mike, yes I'm not using a previous version of your package but also tried to run it directly with the provided command:
app('geocoder')->geocode('Los Angeles, CA')->get();
Unfortunately the same result.
@mikebronner
app('geocoder')->geocode('8.8.8.8')->get();
This command worked.
`Collection {#362 ▼
0 => Address {#363 ▼
-coordinates: Coordinates {#364 ▼
-latitude: 37.386
-longitude: -122.0838
}
-bounds: null
-streetNumber: null
-streetName: null
-subLocality: null
-locality: "Mountain View"
-postalCode: null
-adminLevels: AdminLevelCollection {#365 ▶}
-country: Country {#367 ▶}
-timezone: null
-providedBy: "geo_plugin"
}
] }`
But it's the only one from the provided commands.
Have you tried them all on your server? The others probably won't work on Sierra, like I mentioned earlier. It works perfectly in High Sierra:
php artisan tinker
Psy Shell v0.8.11 (PHP 7.1.9 — cli) by Justin Hileman
>>> dd(app('geocoder')->geocode('Los Angeles, CA')->get());
Illuminate\Support\Collection {#914
#items: array:1 [
0 => Geocoder\Provider\GoogleMaps\Model\GoogleAddress {#903
-id: "ChIJE9on3F3HwoAR9AhGJW_fL-I"
-locationType: "APPROXIMATE"
-resultType: array:2 [
0 => "locality"
1 => "political"
]
-formattedAddress: "Los Angeles, CA, USA"
-streetAddress: null
-intersection: null
-political: "United States"
-colloquialArea: null
-ward: null
-neighborhood: null
-premise: null
-subpremise: null
-naturalFeature: null
-airport: null
-park: null
-pointOfInterest: null
-establishment: null
-subLocalityLevels: Geocoder\Model\AdminLevelCollection {#905
-adminLevels: []
}
-coordinates: Geocoder\Model\Coordinates {#917
-latitude: 34.0522342
-longitude: -118.2436849
}
-bounds: Geocoder\Model\Bounds {#918
-south: 33.7036519
-west: -118.6681759
-north: 34.3373061
-east: -118.1552891
}
-streetNumber: null
-streetName: null
-subLocality: null
-locality: "Los Angeles"
-postalCode: null
-adminLevels: Geocoder\Model\AdminLevelCollection {#919
-adminLevels: array:2 [
1 => Geocoder\Model\AdminLevel {#920
-level: 1
-name: "California"
-code: "CA"
}
2 => Geocoder\Model\AdminLevel {#921
-level: 2
-name: "Los Angeles County"
-code: "Los Angeles County"
}
]
}
-country: Geocoder\Model\Country {#922
-name: "United States"
-code: "US"
}
-timezone: null
-providedBy: "google_maps"
}
]
}```
Unfortunately yes. This following comand is the only i get working.
app('geocoder')->geocode('8.8.8.8')->get();
@mikebronner I just saw an closed ticket with someone else having the same problem.
Is there a way I can provide you some log files or access to the server or application? I try to dig into the package a little deeper when i'm at home later to check the package-code by myself as well.
The only thing i'm not getting is why i get an empty collection even if i provide no API_Key. So maybe there is something i'm missing out before its running the actual query. Cheers, Stan
Did you remove the alias and provider entries from your config/app.php
file? The package is self-registering. Other than that, I have no idea what's going on with your setup. I am unable to reproduce the issue, and suspect that it has something to do with your specific setup.
An empty collection is returned when a result cannot be found, for whatever reason. Please empty your storage/logs/laravel.log
file, run the code in Tinkerer, then see if it logged an error. If so, please provide that. If there is no error being logged, I'm afraid it is something with your setup.
Clone the repo to a folder and try running all the unit tests:
git clone git@github.com:geocoder-php/GeocoderLaravel.git
cd GeocoderLaravel
composer update
vendor/bin/phpunit
@mikebronner
Tinker What line of code are you exactly running in Tinker? At the moment i get an 'geocoder' does not exist or an 'not found ine vil()'code Exception.
Unit Tests The UnitTests all passing locally and on the Ubuntu Server as well.
I replaced my API:Key in your Test-Package to make sure the my key is correct. That worked fine, even with an broken key i got the appropriate error response.
Try your TestCode inside my App I was starting running your tests inside my application:
public function testItResolvesAGivenAddress()
{
$results = app('geocoder')
->using('chain')
->geocode('1600 Pennsylvania Ave., Washington, DC USA')
->get();
}
With the same results: Empty collection.
Cheers, Stan
@StanBarrows you didn't answer if you made sure that you weren't manually registering the provider and alias? I can't really help with configuration issues without having a stacktrace or other information.
My recommendation at this point is to read the README in detail and follow it EXACTLY on a new project, and see if it works there. If it does, see what you did differently, or perhaps what might be conflicting with it.
@mikebronner Sorry for that, I re-arranged my comments and forgot to past it back in. Yes, I made sure everything was setup from scratch and the Providers and Facades were removed. At last step i can give it a shot on a completely new project.
Cheers, Stan
@mikebronner
After a restart and clearing ALL possible caches it worked! Thanks for your help and patience. Glad i can user your awesome work now!
I think it's maybe worth to mention somewhere in the documentation again to clear all caches after every possible change on the query.
Cheers Stan
Good to hear! Yea, I will update the documentation and also create another issue to look into the caching mechanism to make sure that the cache keys are unique.
Locking back, I'm sure it was a caching problem and I fixed the query maybe after your first post 👍
Be sure that you use the right type of key
Screenshot from the google api console :
Thanks for mentioning that @mikehins :)
@StanBarrows How to ' clearing ALL possible caches '? I have exactly the same problem, and simply cache:clear doesn't solve the problem. Thank you in advance
dd(app('geocoder')->geocode('8.8.8.8')->get()); Illuminate\Support\Collection {#763
items: array:1 [
0 => Geocoder\Model\Address {#765 -coordinates: Geocoder\Model\Coordinates {#783 -latitude: 37.751 -longitude: -97.822 } -bounds: null -streetNumber: null -streetName: null -subLocality: null -locality: null -postalCode: null -adminLevels: Geocoder\Model\AdminLevelCollection {#777 -adminLevels: [] } -country: Geocoder\Model\Country {#784 -name: "United States" -code: "US" } -timezone: null -providedBy: "geo_plugin" } ] }
dd(app('geocoder')->geocode('Los Angeles, CA')->get()); Illuminate\Support\Collection {#763
items: []
}
General Information
GeocoderLaravel Version: ^4.0 Laravel Version: 5.5.* PHP Version:>=7.0.0 Operating System and Version: Mac with Laravel Valet
Issue Description
I always receiving an Empty Collection.
`Collection {#363 ▼
items: []
}`
Steps to Replicate
use Geocoder\Laravel\Facades\Geocoder;
$result = Geocoder::geocode('Los Angeles, CA')->get();
dd($result);
Google Place API Key is provided, Any suggestions?