שרון
אולי אתה נתקלת בזה כשקאת את קווי אורך ורוחב של האתרים?
אולי אתה נצקלת בבעיה דומה. אני מנסה מ-Php לגשת לשרת לעדכן קווי אורך
ורוחב מגוגל ואני משתמש בקוד הזה:
הבעיה היא שאני מקבל תוצאה שאם אני מריץ אותה ישירות ה-: אחרי ה- http
נעלמות אם אני מוסיף השורה עובדת טוב ומחזירה לי ערכים ב-Jason
זה הקוד:
function GetGoogle_Lon_Lat($siteAdd,$siteAddNo,$siteCity)
{
$searchSite="http://www.maps.google.com/maps/api/geocode/json?
address=".$siteAdd."+".$siteAddNo."+".$siteCity."+IL&sensor=false";
printf ($searchSite);
$geocode=file_get_contents($searchSite);
$output= json_decode($geocode);
$lat = $output->results[0]->geometry->location->lat;
$long = $output->results[0]->geometry->location->lng;
echo "<br>Latitude : ".$lat;
echo "<br>Longitude : ".$long;
}
זה מה שאני מקבל
http://www.maps.google.com/maps/api/geocode/json?address=המדע+2+יוקנעם
+IL&sensor=false
אם אני מכניס ערכים באנגלית זה עובד טוב
אם ערכים בעברית זה לא עובד ואם אני מעתיק את השורה שהודפסה ומריץ אותה
ישירות בדפדפן ה-: מה-http נעלמים
יש לך רעיון?
נתקלת בזה?
תודה
איציק
בהצלחה.
שרון.
$businessAddress = $address.' '.$city;
//encode the hebrew business address to url value
$businessAddress = urlencode($businessAddress);
//get the json from google
$url = file_get_contents('http://maps.googleapis.com/maps/api/geocode/
json?address='.$businessAddress.'&sensor=false');
//make the json an array
$json = json_decode($url,true);
//assing the latitude and longtitude to variables
$lat = $json['results'][0]['geometry']['location']['lat'];
$lon = $json['results'][0]['geometry']['location']['lng'];