latitude long. pass through Geopoint() ,problem in number format
I have done xml parsing and store result as latitude and longitude in an StringArray and using for loop I store result of lat and longitude in a string named "lat" and "longi" I want to pass these points through GeoPoint() for showing in a map,now the problem is now that i have 43 items in array: "sitesList.getLatitude().size()" when i use in our for loop it force close it is showing only 20 items show when i hard coated it then it is showing all lat long in map so now my qus is how to show all 43 position in mymap???
**if i use this then force close and gives number format exceptions...**
****// for (int i = 0; i < sitesList.getLatitude().size(); i++)****
and when i take max size 20 then no problem occur why???
for(int i=0;i<20;i++)
{
name = sitesList.getLatitude().get(i);
name1 = sitesList.getLongitude().get(i);
Log.i("array_spinner" + i, name);
Log.i("longitiitude"+i,name1);
point = new GeoPoint((int) (Double.parseDouble(name) * 1E6),
(int) (Double.parseDouble(name1) * 1E6));
OverlayItem overlayItem = new Over开发者_如何学GolayItem(point, "Tomorrow ",
"(M gives Bond his mission in Daimler car)");
itemizedOverlay.addOverlay(overlayItem);
}
It seems like a data in your sitesList
contains null values (excatly at position 20) or it contains values, that can'be parsed as Double
.
In first case you are getting NullPointerException
, and in the second one - NumberFormatException
.
P.S. I have seen this bug before... exactly here: Show marker on google map position obtained from xml
精彩评论