지오 코드 자동 완성을 사용했지만 드롭 다운에서 선택하면 주소의 위도와 경도가 표시됩니다.
위도와 경도가 비어있을 때 확인해야하며 게시 된 주소에서 위도와 경도를 가져와야합니다.
lat 및 long에 대한 숨겨진 값이 mapLat 및 mapLong이고 입력 필드 이름이 위치라고 가정합니다.
<html>
<form>
<input type="hidden" name="mapLat">
<input type="hidden" name="mapLong">
<input type="text" name="location">
<input type="submit" name="submit" value="submit">
</form>
</html>
extract($_POST);
if($mapLat =='' && $mapLong ==''){
// Get lat long from google
$latlong = get_lat_long($location); // create a function with the name "get_lat_long" given as below
$map = explode(',' ,$latlong);
$mapLat = $map[0];
$mapLong = $map[1];
}
// function to get the address
function get_lat_long($address){
$address = str_replace(" ", "+", $address);
$json = file_get_contents("http://maps.google.com/maps/api/geocode/json?address=$address&sensor=false®ion=$region");
$json = json_decode($json);
$lat = $json->{'results'}[0]->{'geometry'}->{'location'}->{'lat'};
$long = $json->{'results'}[0]->{'geometry'}->{'location'}->{'lng'};
return $lat.','.$long;
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다