How do I end this function by clicking the end button?

1

button block ion-button (click)="getLoc ()" > start

button block ion-button (click)="getLoc ()" > Finish

When I click the "Start" button, this function takes the current location every 10 seconds, how do I stop collecting the location when I click the finish button?

getLoc () {

                    var intervalo = window.setInterval(function() {
                      // corpo da funcao

                                  var options = {
                                    enableHighAccuracy: true,
                                    timeout: 5000,
                                    maximumAge: 0
                                  };

                                  function success(pos) {
                                    var crd = pos.coords;

                                    console.log('Sua localização é');
                                    console.log('Latitude : ${crd.latitude}');
                                    console.log('Longitude: ${crd.longitude}');
                                    //console.log('More or less ${crd.accuracy} meters.');
                                    // console.log(crd.latitude);

                                  };

                                  function error(err) {
                                    console.warn('ERROR(${err.code}): ${err.message}');
                                  };


                            navigator.geolocation.getCurrentPosition(success, error, options);

                      },5000);



        }
    
asked by anonymous 22.09.2017 / 03:41

0 answers