如何在Google Maps Android中的缩放级别中使用米值? [英] How to use meters value in zoom level in google maps android?

查看:94
本文介绍了如何在Google Maps Android中的缩放级别中使用米值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以前,我是通过硬编码在Google地图中使用缩放级别的.但是现在它来自回应.

Previously I used zoom level in google maps by hardcoding. But now it comes from response.

那么如何通过传递到缩放级别来转换米?在我的代码中,我显示了一个大圆圈图标并指向.因此,对于这两者,我都使用硬编码的缩放级别.但是现在它来自响应.

So how to convert the meters by passing into zoom level? In my code, I am displaying a big circle icon and also points. So for both, I use hardcoded zoom level. But now it comes from response.

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是硬编码的.但是现在它来自回应.

3 is hardcoded one. But now it comes from response.

"range":"1000"//这是米"的响应

"range": "1000" //this comes in response as "meters"

那么如何在上面的逻辑中应用此方法以将米转换为缩放级别?

So how to apply this in above logic to convert from meters to zoom level?

推荐答案

  1. 请添加此Map Utils库:

编译'com.google.maps.android:android-maps-utils:0.4.3'

compile 'com.google.maps.android:android-maps-utils:0.4.3'

  1. 要转换的源代码:

这篇关于如何在Google Maps Android中的缩放级别中使用米值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆