Ionic 3 and leaflet problem with android


#1

Good Morning I have the code, it use for maps with library leaflet, run in chrome, however has this error when install in android:
Geolocation error: Timeout expired
This is de code:
import { Component } from ‘@angular/core’;
import { ViewChild, ElementRef } from ‘@angular/core’;
//import leaflet from ‘leaflet’;
import * as Leaflet from ‘Leaflet’;

@Component({
selector: ‘page-home’,
templateUrl: ‘home.html’
})

export class HomePage {
// @ViewChild(‘map’) mapContainer: ElementRef;
//map: any;
//public center:leaflet.PointTuple;
map: any;
intento:number = 0;
constructor() {
// this.center= [-29.691484, -53.812409];
}

ionViewDidEnter(){
this.leafletMap();
}

leafletMap(){

// this.map=leaflet.map(‘mapId’, {
// center: this.center,
// zoom: 17
// });
// var position =leaflet.tileLayer(‘http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png’, {
// attribution: ‘NETZ Art Soluções em Internet © LeafLet’
// }).addTo(this.map);
// //
// leaflet.marker(this.center).addTo(this.map);
//
this.map = Leaflet.map(‘map’).setView([-0.1836298, -78.4821206], 13);
Leaflet.tileLayer(‘http://{s}.tile.osm.org/{z}/{x}/{y}.png’, {
attribution: ‘AppTuto’,
maxZoom: 18
}).addTo(this.map);

var map = this.map;

//web location
map.locate({ setView: true});

function getLocation() {
this.intento = this.intento + 1;
map.locate({
setView: true,
maxZoom: 16,
timeout: 60000,
enableHighAccuracy: true,
maximumAge: 15000
});
}

//when we have a location draw a marker and accuracy circle
function onLocationFound(e) {
var radius = e.accuracy / 2;

Leaflet.marker(e.latlng).addTo(map)
.bindPopup("Estás dentro de los " + radius + “metros desde este punto”).openPopup();

Leaflet.circle(e.latlng, radius).addTo(map);
}
map.on(‘locationfound’, onLocationFound);

//alert on location error
function onLocationError(e) {
if (this.intento < 10) {
getLocation();
}
alert(e.message);
}
this.map.on(‘locationerror’, onLocationError);
}
}

Help!!. Thank you