Google Maps JavaScript API - Automate Zoom Level?

后端 未结 5 899
执念已碎
执念已碎 2020-12-15 14:01

I\'m working with multiple map markers. Currently I use map.fitBounds(bounds); in my JavaScript to resize the map. bounds contains multiple LatLng

5条回答
  •  太阳男子
    2020-12-15 14:13

    Just use the setZoom function.

    var geocoder = new google.maps.Geocoder();
    geocoder.geocode({ 'address': zipcode }, function(results, status)
    {
        if (status == google.maps.GeocoderStatus.OK)
        {
            map.setCenter(results[0].geometry.location);
            map.setZoom(12);
        }
        else
        {
            alert(zipcode + " not found" + "\nstatus : " + status);
        }
    });
    

提交回复
热议问题