i have installed geocoder following instructions here: https://github.com/geocoder-php/geocoder
and try run example:
require __dir__.'/vendor/autoload.php'; $bingapikey = 'xxxxxxxxxxxxxxxxxxxxxxx'; $curl = new \ivory\httpadapter\curlhttpadapter(); $geocoder = new \geocoder\provider\bingmaps($curl,$bingapikey); $result = $geocoder->geocode('Μπουμπουλίνας 1, 155 62 Χολαργός Αττικής'); when try var_dump $result error:
<b>catchable fatal error</b>: object of class geocoder\model\addresscollection not converted string in <b>c:\mamp\htdocs\wind\geocoding\geocodecheck.php</b> on line <b>21</b><br /> what doing wrong?
from docs:
both geocode() , reverse() methods return collection of address objects
first()retrieves firstaddress;
https://github.com/geocoder-php/geocoder#address--addresscollection
try
$result = $geocoder->geocode('Μπουμπουλίνας 1, 155 62 Χολαργός Αττικής')->first(); based on documentation (therefore limited), else try:
$result = $geocoder->geocode('Μπουμπουλίνας 1, 155 62 Χολαργός Αττικής'); if($result->count() > 0) { echo $result->first(); } else { echo 'no result'; } i'm assuming can this:
$result = $geocoder->geocode('Μπουμπουλίνας 1, 155 62 Χολαργός Αττικής'); for($i=0; $i<$result->count(); ++$i) { echo $result->get($i); } this speculation though, documentation lacking in details , don't have package installed test it.
Comments
Post a Comment