Refresh pins positions in google maps

Imrik13Imrik13 Member
edited January 2018 in Cross Platform with Xamarin

Hi all, I have a crossplatform app that contains some pins to show vehicles location.

All I want to do is to refresh the vehicles locations when they move, as the gps do with our own location.

In the future, I received the location data from a database that is constantly actualized. At the moment, because I don't have any database yet, I'm setting the location value manually.

Have any ideas how I can refresh the pins location and show the new location at the map?

I can't post my map code, it said I cannot post links (but my code hasn't got links :/ ).

Thanks! :)

Best Answer

  • Imrik13Imrik13
    Accepted Answer

    I solve it using this event on a timer:

    private bool TimerCallBack()
    {
        listaPines = loadPines(valores);
        valores++;
        map.Pins.Clear();
        cargarPinesEnMapa();
    
        return true;
    }
    

    Method cargarPinesEnMapa:

    private void cargarPinesEnMapa()
    {
        for (int i = 0; i < listaPines.Count; i++)
            map.Pins.Add((Pin)listaPines[i]);
    }
    

    So, it changes the values every two seconds and it reloads the pins position on the map.

Answers

  • Imrik13Imrik13 Member
    Accepted Answer

    I solve it using this event on a timer:

    private bool TimerCallBack()
    {
        listaPines = loadPines(valores);
        valores++;
        map.Pins.Clear();
        cargarPinesEnMapa();
    
        return true;
    }
    

    Method cargarPinesEnMapa:

    private void cargarPinesEnMapa()
    {
        for (int i = 0; i < listaPines.Count; i++)
            map.Pins.Add((Pin)listaPines[i]);
    }
    

    So, it changes the values every two seconds and it reloads the pins position on the map.

Sign In or Register to comment.