0

尝试在 GoogleMap ( googleMap) 上绘制标记。属性存储在 CSV 文件中,其结构为namecode(主要用作片段)latitudelongitude. 这没有任何错误,但没有正确编译

    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
        }

关于我将如何做到这一点的任何帮助?

4

1 回答 1

0

我发现了问题:CSV 文件的一行中有一个小错误导致它崩溃。

于 2013-03-16T02:33:39.720 回答