开发者

Get latitude and longitude from json file and insert points to google map - Android

{"data":{"columns":["location_id","name","description","latitude","longitude","error","type","type_id","icon_media_id","item_qty","hidden","force_view","allow_quick_travel"],"rows":[[2,"Editor","",43.076014654537,-89.399642451567,25,"Npc",1,0,1,"0","0","0"],[3,"Dow Recruiter","",43.07550842555,-89.399381822662,25,"Npc",2,0,1,"0","0","0"],[4,"Protestor","",43.074933,-89.400438,25,"Npc",3,0,1,"0","0","0"],[5,"State Legislator","",43.074868061524,-89.402136196317,25,"Npc",4,0,1,"0","0","0"]]},"returnCode":0,"returnCodeDescription":null}

I have this JSON string in file. I'm using function to connect to json file, this is my parsing where i'm getting latitude and logitude. What should i do next?

JSONObject data = new JSONObject(convertStreamToString(jsonString)).getJSONObject("data");
                // Get the query value'

                JSONArray Acolumns = data.getJSONArray("columns");
                JSONArray Arows = data.getJSONArray("rows");



                for (int i = 0; i < Arows.length(); i++) {
                    JSON开发者_运维百科Array rec = Arows.getJSONArray(i);
                    //stringJsonResult += "\n rows:" + rec;
                    int latitude = rec.getInt(3);
                    int longitude = rec.getInt(4);

                    //stringJsonResult += "\n  latitude + longitude;
                }

                jsonString.close();
                //JsonResult.setText("\n" + stringJsonResult);

Thanks for help, Michal.

EDIT:: Ok thank you ryanm for help, your app works ;) Is it possible to make JSON array with latitude and longitude for example: {points: {[lat1, long1],[lat2,long2]} and add it to google map? Have somebody diffrent idea to solve my problem?


Check out this app for pointers. It downloads a json string, parses it, and displays lat/lon points on a map view.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜