Is it possible to make the addition of a geopoint in a map more \"automatic\"? I mean, if we have many points to add in the map (more than 100), we don\'t have to add them one b
You'll want to store them in either a SQLite database or some other form of data storage, and then you can pull them in and place them on the map with an ItemizedOverlay, see Google Map View (a tutorial).
Create your array from a database cursor
Cursor cursor = mDbHelper.getItems();
cursor.moveToFirst();
List catchList = new ArrayList();
if (cursor != null && cursor.getCount() > 0) {
for (int i = 0; i < cursor.getCount(); i++) {
CatchItem item = new CatchItem();
item.Latitude = cursor.getDouble(cursor.getColumnIndex("latitude"));
item.Longitude = cursor.getDouble(cursor.getColumnIndex("longitude"));
catchList.add(item);
cursor.moveToNext();
}
}
ItemizedOverlay
List overlays = mMaps.getOverlays();
overlays.clear();
CatchesItemizedOverlay catchOverlays = new CatchesItemizedOverlay(getResources().getDrawable(R.drawable.map_markeroverlay_blue72), this);
for (int i = 0; i < catchList.size(); i++) {
double lat = catchList.get(i).Latitude;
double lng = catchList.get(i).Longitude;
GeoPoint geopoint = new GeoPoint((int)(lat*1E6), (int)(lng*1E6));
catchOverlays.addOverlay(new CatchOverlayItem(this, geopoint, catchList.get(i)));
}
overlays.add(catchOverlays);
CatchesItemizedOverlay
is my own extended ItemizedOverlay
(I needed custom functionality). The catchList object is just a custom object that has latitude and longitude.
Hopefully this works for you.