Geolocation관련 api 활용중 질문드립니다

안녕하세요,

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);
	}
};

options의 timeout은 언급하신 것과는 다릅니다.
timeout이라고 하면 위치 정보를 받기 전까지 대기하는 시간입니다.
그 시간 내에 위치 정보를 받지 못하면 에러를 발생할 것입니다.

geolocation 객체 내부에서
사용자 위치정보를 알기 위해 얼마나 자주 요청하는지는 알 수 없습니다만,
일단 새로운 위치값이 측정되면 이에 반응하여 업데이트하는 것으로 보이며
watchPosition에 등록한 콜백 함수를 반복해서 실행하는 것은 맞습니다.

아래 문서를 보시면 더 정확한 내용을 확인할 수 있습니다.
https://developer.mozilla.org/ko/docs/WebAPI/Using_geolocation

답변 감사드립니다.

watchPosition함수의 첫번째 매개변수로 위치정보가 변경됐을 시 실행할 콜백함수를 지정하면 되겠군요.

두더지님, 혹시 생성한 마커의 position을 변경할 수 있는 방법은 없을까요?

저는 콜백함수로 마커의 위치를 옮기고 싶어서요…ㅎㅎ

var marker = new daum.maps.Marker({
map: map,
position: new daum.maps.LatLng(33.450701, 126.570667)
});

위의 marker의 position만 바꿔, 마커의 위치를 옮기고 싶다면 어떻게하면 좋을까요?

혹시 마커를 제거하고 새로 생성하는 방법으로 해야하는건가요?

저번에 폴리라인의 setPath랑 비슷한 질문이네요 ㅎ

마커 관련 문서를 보시면 해결 할 수 있을거에요.
http://apis.map.daum.net/web/documentation/#Marker_setPosition