0

I have a set of latitudes and longitudes saved in MySQL database. I plot them on my map using:

 for (int i = 0; i < jArray.length(); i++) {
            JSONObject json_data = jArray.getJSONObject(i);
                    double lat = json_data.getDouble("lat");
                    double lng= json_data.getDouble("long");
            MyItem offsetItem = new MyItem(lat, lng);
            mClusterManager.addItem(offsetItem);

(I use Async Task to fetch the location and have kept a Timer to keep calling that Task) These locations correspond to particular vehicles, hence I plan to add that using this link

Showing custom InfoWindow for Android Maps Utility Library for Android.

My question is that once the location of a particular entry is updated in the database I need to find that marker and move/animate the marker to new new positon.

How can I achieve this?

Community
  • 1
  • 1
Rushabh M Shah
  • 59
  • 1
  • 3
  • 9

1 Answers1

1

When you create your markers you need to store them somewhere, like an array or list. You need to have each marker identified in a way that associates a marker with the location. Markers have a ID property that is unique across the map, so you can try using that. Alternatively, you can use the Title or content in the InfoWindow to differentiate the markers. You can also try using the position the marker assuming you can retrieve the "old" position before you update it. With whatever method you use, once you get a match, you can then update the marker position with setPosition.

There are also some third party libraries available with which you can retrieve markers with.

Andy
  • 2,374
  • 3
  • 17
  • 20
  • clusterManager automatically creates a list. Had to use a Handler to create a new thread that can alter the UI of the app, but finally code worked! Thanks alot. – Rushabh M Shah Feb 24 '15 at 16:57