zoom over specific route google map

前端 未结 9 1227
感动是毒
感动是毒 2021-02-05 11:23

I have a list of random latitude and longitude points and I am drawing a route between them. My question is how to bound this route within google map I made below utili

9条回答
  •  眼角桃花
    2021-02-05 12:05

    you can do one thing, find out the distance between 2 latitude and longitude and make check over distance that you got.See,how it work . It's a trick it might useful for you.

    googleMap.moveCamera(CameraUpdateFactory.newLatLng(reachLocationLatLng));
    if (dist > 2 && dist <= 5) {
    googleMap.animateCamera(CameraUpdateFactory.zoomTo(13.0f));
    mapZoomLevel = 12;
    } else if (dist > 5 && dist <= 10) {
    googleMap.animateCamera(CameraUpdateFactory.zoomTo(12.0f));
    mapZoomLevel = 11;
    } else if (dist > 10 && dist <= 20) {
    googleMap.animateCamera(CameraUpdateFactory.zoomTo(11.0f));
    mapZoomLevel = 11;
    } else if (dist > 20 && dist <= 40) {
    googleMap.animateCamera(CameraUpdateFactory.zoomTo(10.0f));
    mapZoomLevel = 10;
    } else if (dist > 40 && dist < 100) {
    googleMap.animateCamera(CameraUpdateFactory.zoomTo(9.0f));
    mapZoomLevel = 9;
    } else if (dist > 100 && dist < 200) {
    googleMap.animateCamera(CameraUpdateFactory.zoomTo(8.0f));
    mapZoomLevel = 8;
    } else if (dist > 200 && dist < 400) {
    googleMap.animateCamera(CameraUpdateFactory.zoomTo(7.0f));
    mapZoomLevel = 7;
    } else if (dist > 400 && dist < 700) {
    googleMap.animateCamera(CameraUpdateFactory.zoomTo(6.0f));
    mapZoomLevel = 7;
    } else if (dist > 700 && dist < 1000) {
    googleMap.animateCamera(CameraUpdateFactory.zoomTo(5.0f));
    mapZoomLevel = 6;
    } else if (dist > 1000) {
    googleMap.animateCamera(CameraUpdateFactory.zoomTo(4.0f));
    mapZoomLevel = 5;
    } else {
    googleMap.animateCamera(CameraUpdateFactory.zoomTo(14.0f));
    mapZoomLevel = 14;
    }
    

    Thanks hope this will help you.

提交回复
热议问题