0

i have problem with google map v2 marker

so.. create marker on map works fine but... I after 12s change position and i want marken setPosition not to create new marker so my code

Timer timer = new Timer();
    timer.scheduleAtFixedRate(new TimerTask(){

        GetDataFromWeb GDFW = new GetDataFromWeb();

        public void run() {

            GDFW.doInBackground("a");
            GDFW.execute(); 

            for(int i = 0; i < GDFW.getList().size(); i++){

                lat = Double.valueOf(GDFW.getList().get(i).lat);
                log = Double.valueOf(GDFW.getList().get(i).lot);

                contactList.add(new LatLng(lat, log));

            }

                marker(m);  

        }

}, 12000, 12000);

i add in list lat and log when i create new marker on map

Runnable updateMarker = new Runnable() {

         GetDataFromWeb GDFW = new GetDataFromWeb();

            public void run() {

                 for (LatLng latLon : contactList) {

                        marker = map.addMarker(new MarkerOptions()
                            .position(latLon)
                            .title("Hello world")
                        );
                 }


             contactList.clear(); 

         }
     };
     handler.postDelayed(updateMarker, MARKER_UPDATE_INTERVAL);
    }

adter create marker how in marker setPostition? not clear all marker and create new

Vykintas
  • 401
  • 1
  • 8
  • 23
  • `marker.setPosition(new LatLng(lat, lng))` – etienne May 02 '13 at 08:36
  • everything would fine, but when i setPosition on marker app crash because on map marker two so... I understand the marker name one should be marker1.setPosition(new LatLng(lat, lng)); marker2.setPosition(new LatLng(lat, lng)); how create marker name? – Vykintas May 02 '13 at 09:30
  • You could keep a reference to your markers with a member `ArrayList`, for instance – etienne May 02 '13 at 09:46
  • maybe you can help with code? bicause i first create marker on map and add to ArrayList when i set new possition, when i create new marker on map in map show marker but when i set new possition marker app crash... – Vykintas May 02 '13 at 10:24
  • Paste logcat output, please. – MaciejGórski May 03 '13 at 09:26

0 Answers0