如何在谷歌地图android中使用缩放级别的米值?

时间:2018-03-08 07:36:42

标签: android google-maps google-maps-markers google-maps-android-api-2

之前我通过硬编码在谷歌地图中使用缩放级别。但现在它来自回应。

那么如何通过进入缩放级别来转换米?在我的代码中,我正在显示一个大圆圈图标并且还指向。所以对于两者,我使用硬编码缩放级别。但现在它来自回应。

LatLng retailerPosition = new LatLng(Double.parseDouble(retailerLatitude), Double.parseDouble(retalerLongitude));
    mMap.addMarker(new MarkerOptions().position(retailerPosition).title("").icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_circle_red)));
    mMap.moveCamera(CameraUpdateFactory
            .newLatLngZoom(retailerPosition, 3)); //3 hardcoded one. 

for (int i = 0; i < listLocation.size(); i++) {
            LatLng sitePosition = new LatLng(Double.parseDouble(listLocation.get(i).getRetLatitude()), Double.parseDouble(listLocation.get(i).getRetLongitude()));
            mMap.addMarker(new MarkerOptions().position(sitePosition).title("").icon(BitmapDescriptorFactory.fromResource(R.drawable.round)));
            mMap.moveCamera(CameraUpdateFactory
                    .newLatLngZoom(sitePosition, 3)); //3 hardcoded one
        }

3是硬编码的。但现在它来自回应。

“range”:“1000”//这是“米”的响应

那么如何在上面的逻辑中应用它来从米转换到缩放级别?

1 个答案:

答案 0 :(得分:1)

  1. 请添加此Map Utils库:
  2. 编译'com.google.maps.android:android-maps-utils:0.4.3'

    1. 要转换的源代码:
    2. enter image description here