【问题标题】:Find center and zoom into all LatLng找到中心并放大所有 LatLng
【发布时间】:2020-09-02 00:21:52
【问题描述】:

我有多个LatLng 使用这个库:https://pub.dev/packages/google_maps_flutter 如何获得它们的中心并放大地图,以便所有 LatLng 都可见,但离屏幕不太远?

【问题讨论】:

    标签: algorithm google-maps flutter dart


    【解决方案1】:

    我在一个类似的问题上发现了这个,所以我希望它适用... (Center/Set Zoom of Map to cover all visible Markers?)

    var markers = [];//some array
    var bounds = new google.maps.LatLngBounds();
    for (var i = 0; i < markers.length; i++) {
     bounds.extend(markers[i]);
    }
    
    map.fitBounds(bounds);
    

    可能看看他们的文档:https://developers.google.com/maps/documentation/javascript/reference/map#Map.fitBounds

    【讨论】:

    • 谢谢,之前看过那个答案,但我不认为flutters librry有extend
    猜你喜欢
    • 1970-01-01
    • 2019-01-22
    • 1970-01-01
    • 2013-02-01
    • 2016-11-10
    • 1970-01-01
    • 1970-01-01
    • 2020-04-13
    • 2019-05-04
    相关资源
    最近更新 更多