admin管理员组文章数量:1023242
I observer the position of a user like so
_someFunc() {
navigator.geolocation.watchPosition((position) => {
...
)};
}
_someFunc()
is called in an _onPress()
. In another onPress()
I want to stop the watchPosition
. Doing that, I use the stopObserving
like (badly?) documented here.
On another onPress()
I simply call
_anotherSomeFunc() {
navigator.geolocation.stopObserving();
}
However, that gives me the warning:
Called stopObserving without existing subscriptions.
I have no idea what to make of it. What kind of subscriptions?
I observer the position of a user like so
_someFunc() {
navigator.geolocation.watchPosition((position) => {
...
)};
}
_someFunc()
is called in an _onPress()
. In another onPress()
I want to stop the watchPosition
. Doing that, I use the stopObserving
like (badly?) documented here.
On another onPress()
I simply call
_anotherSomeFunc() {
navigator.geolocation.stopObserving();
}
However, that gives me the warning:
Called stopObserving without existing subscriptions.
I have no idea what to make of it. What kind of subscriptions?
Share Improve this question asked Sep 25, 2017 at 12:28 four-eyesfour-eyes 12.6k37 gold badges130 silver badges255 bronze badges1 Answer
Reset to default 7You should save the watchId returned by navigator.geolocation.watchPosition , and then call clearWatch:
watchId = navigator.geolocation.watchPosition((position) => {
...
}
);
...
navigator.geolocation.clearWatch(watchId);
navigator.geolocation.stopObserving();
I observer the position of a user like so
_someFunc() {
navigator.geolocation.watchPosition((position) => {
...
)};
}
_someFunc()
is called in an _onPress()
. In another onPress()
I want to stop the watchPosition
. Doing that, I use the stopObserving
like (badly?) documented here.
On another onPress()
I simply call
_anotherSomeFunc() {
navigator.geolocation.stopObserving();
}
However, that gives me the warning:
Called stopObserving without existing subscriptions.
I have no idea what to make of it. What kind of subscriptions?
I observer the position of a user like so
_someFunc() {
navigator.geolocation.watchPosition((position) => {
...
)};
}
_someFunc()
is called in an _onPress()
. In another onPress()
I want to stop the watchPosition
. Doing that, I use the stopObserving
like (badly?) documented here.
On another onPress()
I simply call
_anotherSomeFunc() {
navigator.geolocation.stopObserving();
}
However, that gives me the warning:
Called stopObserving without existing subscriptions.
I have no idea what to make of it. What kind of subscriptions?
Share Improve this question asked Sep 25, 2017 at 12:28 four-eyesfour-eyes 12.6k37 gold badges130 silver badges255 bronze badges1 Answer
Reset to default 7You should save the watchId returned by navigator.geolocation.watchPosition , and then call clearWatch:
watchId = navigator.geolocation.watchPosition((position) => {
...
}
);
...
navigator.geolocation.clearWatch(watchId);
navigator.geolocation.stopObserving();
本文标签: javascriptHow to call stopObserving() from navigatorgeolocation properlyStack Overflow
版权声明:本文标题:javascript - How to call stopObserving() from navigator.geolocation properly? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745599682a2158381.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论