I got address, latitude, langitude from foursquare site,
that latitude and longitude are implemented in google map,
then display google map marker is wrong place,
How to get correct latitude and longitude using address
// get logitude and latitude
$address=$param['address'].', '.$param['city'].', '.$param['state'].', '.$param['country'];
$address = urlencode($address);
$json = file_get_contents("http://maps.google.com/maps/api/geocode/json...");
$decoded = json_decode($json, true);
if(isset($decoded['results'][0]['geometry']['location']['lat']) && isset($decoded['results'][0]['geometry']['location']['lng'])){
$param['latitude'] = $decoded['results'][0]['geometry']['location']['lat'];
$param['longitude'] = $decoded['results'][0]['geometry']['location']['lng'];
}else{
$param['latitude'] = '';
$param['longitude'] = '';
}
// end of longitude and latitude
Here is another code
/// get loaction through longitude and latidute
$url = 'http://maps.googleapis.com/maps/api/geocode/json...';
$json = file_get_contents($url);
$datas=json_decode($json);
$status = $datas->status;
if($status=="OK"){
$param['address'] = $datas->results[0]->address_components[0]->short_name.' '.$datas->results[0]->address_components[1]->short_name;
$param['city'] = $datas->results[0]->address_components[3]->long_name;
$param['state'] = $datas->results[0]->address_components[6]->short_name;
$param['country'] = $datas->results[0]->address_components[7]->short_name;
$param['zipcode'] = $datas->results[0]->address_components[8]->short_name;
}else{
$param['address'] = "";
$param['city'] = "";
$param['state'] = "";
$param['country'] = "";
$param['zipcode'] = "";
}
URL: http://maps.google.com/maps/api/geocode/json...
Result is : latitude and longitude 51.51212289999999,-0.1335969 that latitude and longitude is wrong place display
0 Comments
Please add nice comments or answer ....