안녕하세요,
geolocation.getCurrentPosition 및 gelocation.watchPosition 메서드 이용하여 접속자의 위치를 추적하는 것을 구현중입니다. 그런데 아래와 같이 watchPosition 메서드를 활용하였을 때, 접속자의 위치를 지정된 option때 마다, 혹은 보다 정확한 위치가 파악될 때 마다 실제로 리로딩 하여 추적하는지 궁금하여 질문합니다.
getEngineerInfo(){
const {engineers} = this.state;
if(navigator.geolocation){
const options = {timeout : 5000};
const engineer = navigator.geolocation.watchPosition((position) => {
let arr = engineers.slice();
let lat = position.coords.latitude,
lon = position.coords.longitude;
//로그인 정보를 받아와 id name값 입력
let userId = 'jk',
userName = 'jkLee';
let user = {
position : {
lat,
lon
},
Id : userId,
name : userName,
idx : arr.length,
marker : new window.daum.maps.Marker({
position : new window.daum.maps.LatLng(lat,lon)
}),
infoWindow : new window.daum.maps.InfoWindow({
content : userName
})
};
arr.push(user);
this.setState({
engineers : arr
});
}, () => {alert('error')}, options);
}
};