Reputation: 8729
What is the difference between getCurrentPosition()
and watchPosition()
. I read several articles about getCurrentPosition()
and watchPosition()
. But none of was clear to me. As far as I'm understand getCurrentPosition()
update location only one time But watchPosition()
continuously update location. I'm I right??
Upvotes: 2
Views: 10182
Reputation: 5711
watchPosition
fired each time your device position changes (with interval specified in fn params). getCurrentPostion
only once.
watchPosition
actually analogue of setInterval
fn and also returns id that can be used to stop iterative process by using clearWatch
.
Upvotes: 0
Reputation: 51
getCurrentPosition()
gives currentPosition latitude and longtitude values,which fires only once. Where as watchPosition()
gives currentPosition latitude and longtitude values continuously. If position changed(assume you are in a moving vehicle,then watchPosition()
will give result.Then you will come to know the result of this )
Upvotes: 5
Reputation: 4995
You are correct. The getCurrentPosition()
callback is fired once and watchPosition()
callback is fired continuously. Good reading on this here.
Upvotes: 2