Geolocalization system like google maps


#1

Hi guys, I would like to create a geolocalitazion system that tracks the user position also when he is moving himself, such as google maps…

I have tried my self by adding and removing a marker in the map, which indicates the user position, every time that I take a new position but it seems that the app crashes as soon as it has to remove the old marker and has to add the new one…
And I have also noticed that the location data isn’t send regularly, sometimes after 1 minutes, sometimes after 20 seconds… I don’t know why

Here is a part of the home page’s code

watchId = geolocation.watchLocation(
        function (loc) {
        if (loc) {
            if (firstime)
           { 
            mapFunction.setUserMarker(mapView,viewModel.latitude,viewModel.longitude);
            firstime=false;
           }
            else
            mapFunction.editUserMarker(mapView,viewModel.latitude,viewModel.longitude);
          }
        },
        { desiredAccuracy: Accuracy.high, updateDistance: 0.1, minimumUpdateTime: 100 },
        function (e) {
            console.log("Error: " + e.message);
        });

These function are called from the home page

function setUserMarker(map,lat,lng)
{
    userMarker.position=mapsModule.Position.positionFromLatLng(lat,lng);
    userMarker.title="You are here";
    userMarker.snippet="Latitude: "+lat+", Longitude: "+lng;
    
    userMarker.userData={type: 'userMarker' };
    map.addMarker(userMarker);

}

function editUserMarker(map,lat,lng)
{
    var marker=map.findMarker(function(toRemove){
        return toRemove.userData.type==='userMarker';
    })
    map.removeMarker(marker);
    setUserMaker(map,lat,lng);
}

#2

I know this is a rather late response, but did you get anywhere with this? If not can you share the stack trace when the error happened?