Google Maps v2 Set Zoom Level

前端 未结 5 831
遇见更好的自我
遇见更好的自我 2021-02-12 16:46

When I launch Google maps in Android, it shows the whole world. What do i need to change so as to set the zoom to the marker? Here are the codes. Thanks

                 


        
5条回答
  •  遇见更好的自我
    2021-02-12 17:30

    The following code may do the trick:

        function addMarker(lat, lng, info) {
        var pt = new google.maps.LatLng(lat, lng);
        bounds.extend(pt);
    

    You can try the following too:

        var pt = new google.maps.LatLng(lat, lng);
        map.setCenter(pt);
        map.setZoom(your desired zoom);
    

    Edit:

     map.moveCamera( CameraUpdateFactory.newLatLngZoom(new LatLng(xxxx,xxxx) , 14.0f) );//where 14.0 is the zoom level
    

提交回复
热议问题