Json LatLong值为mapActivity

时间:2016-04-15 16:54:55

标签: android google-maps arraylist hashmap

我通过Json接收了lat和long值并保存在ArrayList中然后我将此Array列表传递给MapAcitivity

    matchFixture = jsonObj.getJSONArray(TAG_FIXTURE);
                Log.d("json aray", "user point array");
                int len = matchFixture.length();
                Log.d("len", "get array length");
                for (int i = 0; i < matchFixture.length(); i++) {
                    JSONObject c = matchFixture.getJSONObject(i);
                    String matchId = c.getString(TAG_Lat);
                    Log.d("matchId", matchId);
                    String teamA = c.getString(TAG_Lon);
                    Log.d("teamA", teamA);

                    //  hashmap for single match
                     matchFixtures = new HashMap<String, String>();
                    // adding each child node to HashMap key => value
                    matchFixtures.put(TAG_Lat matchId);
                    matchFixtures.put(TAG_Long, teamA);

                    matchFixtureList.add(matchFixtures);

这是我传递值的方式

Iterator myVeryOwnIterator = matchFixtures.keySet().iterator();
    while(myVeryOwnIterator.hasNext()) {
        String key=(String)myVeryOwnIterator.next();
        String value=(String)matchFixtures.get(key);

这就是我在地图活动中收到的方式

HashMap<String, String> hm = (HashMap<String, String>) getIntent().getExtras().get("hashMapKey");

    Iterator myVeryOwnIterator = hm.keySet().iterator();
    while (myVeryOwnIterator.hasNext()) {
        String key = (String) myVeryOwnIterator.next();
        String value = (String) hm.get(key);
        for (int i = 0; i <=1; i++){}

但是现在我不知道如何以适合特定latlog的顺序获取这些值以在地图上显示地点它基本上用于地图上的多个标记

1 个答案:

答案 0 :(得分:0)

我建议您使用模型类。

class Model {
    public float homeLat;
    public float homeLng;
    public float universityLat;
    public float universityLng;
}

您可以为每个条目创建模型类的对象,并将其放在列表中。

Model model = new Model();
model.homeLat = <The Value from Json>
...
matchFixtureList.add(model);

然后在您的活动中,当您阅读列表值时,您可以获得特定的lat和long以显示标记。