Scenario:Using OSM in android ,user draws the path manually on map and clicks on save button, to save in database as a string.
Polyline myPolyline;
/*
updating myPolyline here
*/
SavePathButton.setOnClickListener(new View.OnClickListener()
{
public void onClick(View arg0)
{
String tempGeoPointString="Begin";
String fullPathStore="Begin ";
List<GeoPoint> myPathPoints=new ArrayList<GeoPoint>(myPathOverLay.getNumberOfPoints());
Collections.copy(myPathPoints, (myPolyline.getPoints()));
for (int i = 0; i < myPathPoints.size(); i++)
{
GeoPoint tempGeoPoint = myPathPoints.get(i);
tempGeoPointString= String.valueOf(tempGeoPoint.getLatitude())+"#"+String.valueOf(tempGeoPoint.getLongitude());
fullPathStore=fullPathStore+tempGeoPointString;
}
}
Log.d("Full Path is ",fullPathStore);
Log.d("PolyLine Size",myPolyline.getNumberOfPoints());
Log.d("PathPoints size",myPathPoints.size()
});
Here's reference to Polyline class
myPolyline.getNumberOfPoints() is non zero,but the fullPathStore is not updated and myPathPoints.size() remains zero in the log. Collecions.copy is not used correctly?