4

i am making a employee tracker in which i will fetch all employee current Lat long after every 30 sec and update on server and then Admin module will fetch the Lat-long of of each employee from server and update the eisting marker position.

So please tell me how to update the 100 markers position without effecting the UI thread in android.

please help its very important for me.

1 Answers1

2

You can update your UI after every 30sec using handler.Create a separate method that fetch and display marker on map.

Use below code in your activity -

    Handler UI_HANDLER = new Handler();
    UI_HANDLER.postDelayed(UI_UPDTAE_RUNNABLE, 30000);

and Below is Runnable method put any where in your activity -

Runnable UI_UPDTAE_RUNNABLE = new Runnable() {

    @Override
    public void run() {
        drawAllMarker();//Method that will get employee location and draw it on map
        UI_HANDLER.postDelayed(UI_UPDTAE_RUNNABLE, 30000);
    }
};

Hope it will help you.

Ravi Bhandari
  • 4,682
  • 8
  • 40
  • 68
  • what the user fill do zoom in and zoom out only? – Ravi Bhandari Apr 29 '15 at 06:17
  • user can also click on the markers which will show up an infowindow. – Android Beginner Apr 29 '15 at 06:19
  • Thanx man, 1 last question..changing position of the existing marker will move the marker to that particular position like in other tracking apps or not? – Android Beginner Apr 29 '15 at 06:26
  • means you want to drag and drop marker?Is i am correct? – Ravi Bhandari Apr 29 '15 at 06:31
  • No, as i mentioned above i am creating an employee tracker application so i need to move the existing marker of that particular employee to the current position of that employe in the map – Android Beginner Apr 29 '15 at 10:33
  • Yes it will be done by your method that will find all employee current location then you have to clear map so all old marker remove from map and then draw marker with new location of each employee. Marker will not move you have to remove previous location marker from map and draw new marker at updated location.Hope you will got my point. – Ravi Bhandari Apr 29 '15 at 10:47
  • This line - `UI_HANDLER.postDelayed(UI_UPDTAE_RUNNABLE, 30000);` fails compilation. Change it to `UI_HANDLER.postDelayed(this, 30000);` in order to make it work – Suhas Apr 07 '17 at 16:16