Trying to draw markers on a GoogleMap ( googleMap
). The properties are stored in a CSV file structured as name
, code
(which is used primarly as a snippet), latitude
and longitude
. This doesn't have any errors, but doesn't compile properly
String name;
String code;
String latitude;
String longitude;
String fileName;
fileName = "sleepertrain5/assests/stations.csv";
InputStream is = null;
try {
is = getAssets().open(fileName);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
try {
String line;
while ((line = reader.readLine()) != null) {
String[] RowData = line.split(",");
name = RowData[0];
code = RowData[1];
latitude= RowData[2];
longitude=RowData[3];
String latAmount=latitude;
double amount1=Float.parseFloat(latAmount);
String longAmount=latitude;
double amount2=Float.parseFloat(longAmount);
googleMap.addMarker(new MarkerOptions()
.position(new LatLng(amount1, amount2))
.title(name)
.snippet("Station code: "+ code));
}
}
catch (IOException ex) {
// handle exception
}
finally {
try {
is.close();
}
catch (IOException e) {
// handle exception
}
Any help as to how I would do this?
我发现了问题:CSV文件的一行中有一个小错误,导致崩溃。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.