# Where to put Geolocation.watchPosition?

**URL:** <https://forum.ionicframework.com/t/where-to-put-geolocation-watchposition/141674>\
**Category:** ionic-v3\
**Created:** [September 13, 2018, 8:19pm UTC](https://forum.ionicframework.com/t/where-to-put-geolocation-watchposition/141674 "2018-09-13T20:19:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jorgster](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@jorgster](https://forum.ionicframework.com/u/jorgster)\
**Post date:** [September 13, 2018, 8:19pm UTC](https://forum.ionicframework.com/t/where-to-put-geolocation-watchposition/141674/1 "2018-09-13T20:19:24Z")

</div>

Hello dear community,

I’m seeing different results on each IONIC SERVE I run, when implementing the Geolocation function WatchPosition in the brackets after the Constructor in app.component.ts.

Sometimes it runs and sometimes dont. On Android it works perfectly, while on iOS it doesn’t work at all. And in the IONIC SERVE version it’s shifty.

I’ve also tried to put it in the brackets after the constructor in a provider, but then it’s also acting kind of cracy.  
This is the piece of code I’m implementing:

```auto
      let options = {
        enableHighAccuracy: true,
        timeout: 8000,
        maximumAge: 7000,
      };

      let watch = this.geolocation.watchPosition(options);
      watch.subscribe((data) => {
        this.userLocation = {lat: data.coords.latitude, lng: data.coords.longitude};

        // data can be a set of coordinates, or an error (if an error occurred).
        this.events.publish('theNewLocationFromOnLocate', [data.coords.latitude, data.coords.longitude]);
        console.log("Location from LocationsProvider ", data.coords.latitude, ' ', data.coords.longitude);
      });

```

Hoping for an answer…

---

<div class="post-metadata">

**Author:** ![Ratikanta](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/ratikanta/32/109400_2.png) [@Ratikanta](https://forum.ionicframework.com/u/Ratikanta)\
**Post date:** [December 19, 2019, 11:32am UTC](https://forum.ionicframework.com/t/where-to-put-geolocation-watchposition/141674/2 "2019-12-19T11:32:07Z")

</div>

Sorry, I do not have answer for this question but, how do you clear the watch? Do you just unsubscribe?

---

<div class="post-metadata">

**Author:** ![EinfachHans](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/einfachhans/32/130917_2.png) [@EinfachHans](https://forum.ionicframework.com/u/EinfachHans)\
**Post date:** [December 19, 2019, 12:59pm UTC](https://forum.ionicframework.com/t/where-to-put-geolocation-watchposition/141674/3 "2019-12-19T12:59:37Z")

</div>

I think there is a function `stopWatch()` or something like this, isn’t it?

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2021, 9:17pm UTC](https://forum.ionicframework.com/t/where-to-put-geolocation-watchposition/141674/4 "2021-07-19T21:17:27Z")

</div>


