如何使地图适合在地图上显示json数组中的所有标记

时间:2016-12-04 06:46:04

标签: android google-maps

我有来自json的坐标,我想在地图中显示它们,这里显示标记,但其中一些不显示我想设置缩放以适合在地图中显示所有标记,我该怎么办?

     JSONArray postsJson = success.getJSONArray("now");
                        for (int i = 0; i < postsJson.length(); i++) {
  Order_Start_Lat=c.getDouble("order_start_latitude");
                                   Order_Start_Lng=c.getDouble("order_start_longitude");


                            MarkerOptions m = new MarkerOptions()
                                    .title(client_name)
                                    .position(new LatLng(Order_Start_Lat,Order_Start_Lng));
                            map.addMarker(m);
                            LatLngBounds.Builder builder = new LatLngBounds.Builder();
                            builder.include(new LatLng(Order_Start_Lat,Order_Start_Lng));
                            LatLngBounds bounds = builder.build();
                            map.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 20));

0 个答案:

没有答案