Geolocalization system like google maps


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)
        { 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.title="You are here";
    userMarker.snippet="Latitude: "+lat+", Longitude: "+lng;
    userMarker.userData={type: 'userMarker' };


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


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?