자신의 위치를 wr_1,2 값에 넣고 싶은데요 navigator.geolocation 잘안되네요
본문
<div class="bo_w_tit write_div">
<label for="wr_subject" class="sound_only">위치<strong>필수</strong></label>
<div id="autosave_wrapper" class="write_div">
<input type="text" id="wr_1" name="wr_1" value="" class="frm_input full_input required" size="50">
<input type="text" id="wr_2" name="wr_2" value="" class="frm_input full_input required" size="50">
<script>
$(document).ready(function(){
if('geolocation' in navigator) {
/* 위치정보 사용 가능 */
//alert("가능");
} else {
/* 위치정보 사용 불가능 */
//alert("불가능");
}
navigator.geolocation.getCurrentPosition(function(pos) {
console.log(pos);
var latitude = pos.coords.latitude;
var longitude = pos.coords.longitude;
alert(latitude);
document.getElementById("wr_1").value = latitude;
document.getElementById("wr_2").value = longitude;
alert("현재 위치는 : " + latitude + ", "+ longitude);
});
});
</script>