繁体   English   中英

如何通过JSON在地图上添加这些位置?

[英]How can I add these locations on the map from JSON?

我的项目正在运行,它已经显示了设备的当前位置。 我的问题是有一个包含4个地址的JSON 我应该在地图上添加这些地址。 如何添加这些位置以从JSON映射?

此JSON的网站: https : //instalyticsdbplandiag814.blob.core.windows.net/mobiversite/location.json

试试以下代码片段:

    try {
        JSONObject jsonObject= new JSONObject(jsonAsString);

        JSONArray jsonArray=jsonObject.getJSONArray("locations");

        for(int i=0;i<jsonArray.length(); i++){

            JSONObject item = jsonArray.getJSONObject(i);

            String name=item.getString("name");

            String lattitude= item.getString("lattitude");

            String longitude= item.getString("longitude");


            //process as you want
        }


    } catch (JSONException e) {
        e.printStackTrace();
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM