주소로 위도와 경도를 구할 수 있습니다. 하지만 주소를 모르는 경우에는 PHP를 사용하여 내가 어디에 있는지 또는 내 주소를 알 수 있습니까? 이 코드로, 나는 CamMob의 위도와 longitute 얻을 수 있습니다 :현재 위치의 주소를 얻는 방법 PHP
<?php
$address = urlencode("#18C, Street 584, Toul Kork, Phnom Penh, Cambodia");
//here is the google api url
$url = "http://maps.googleapis.com/maps/api/geocode/json?address=$address&sensor=false";
//get the content from the api using file_get_contents
$getmap = file_get_contents($url);
//the result is in json format. To decode it use json_decode
$googlemap = json_decode($getmap);
//get the latitute, longitude from the json result by doing a for loop
foreach($googlemap->results as $res){
$address = $res->geometry;
$latlng = $address->location;
$formattedaddress = $res->formatted_address;
echo "Latitude: ". $latlng->lat ."<br />". "Longitude:". $latlng->lng;
}
?>
을하지만 내 주소를 모르는 경우, 어떻게 그것을 얻을 수 있나요?
을 사용하여 현재 위치를 찾으려면이 IP 주소를 'IP 주소 $의 _SERVER'http_host를 사용]을 사용하여 찾을 수 있습니다, 어떤 입력을 할 있다? –
사실, 사용자의 새 패스를 업데이트하기 위해 현재 사용자의 주소를 원하지만 사용자가있는 위치를 알지 못합니다. – malinchhan
이 위도/경도가 가장 가까운 10 개의 가장 가까운 위치를 선택하기를 원합니다! – malinchhan