0

当我在地图上有多个位置时,需要设置缩放以使所有位置可见。我正在使用谷歌地图 api v3。

我正在使用的代码如下

function initialize() {
    var myLatlng = new google.maps.LatLng(20.798362600000000000, -156.331925299999970000);

    var mapOptions = {
        zoom: 10,
        center: myLatlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };

    map = new google.maps.Map(document.getElementById('map-canvas'),mapOptions);

    addMarker(21.29539299, -157.8258667,'2525 South King Street,Honolulu HI 96826','Down to Earth','wholesale','restaurant');
    addMarker(20.87521935, -156.68008423,'658 Front St, lahaina HI 96761','Veg Out','wholesale','restaurant');
    addMarker(20.73747253, -156.45561218,'1847 S Kihei Rd,kihei HI 96753','Rodeo Kihei','wholesale','retailer');
    addMarker(20.9165287, -156.38095093,'127 Hana Hwy,Paia HI 96779','Test User','wholesale','retailer');
    addMarker(21.29226112, -157.82328796,'2525 South King Street,Honolulu HI 96826','Some User','wholesale','both');
    addMarker(20.91534615, -156.38002014,'49 Baldwin Ave.,Paia HI 96779','Mana Foods 2','wholesale','retailer');
    addMarker(20.88739586, -156.4566803,'340 Hana Hwy,, HI,Kahului HI 96732','Alive and Well 2','wholesale','restaurant');

    //addMarker(, ,'','','delivery');
}

google.maps.event.addDomListener(window, 'load', initialize);
4

1 回答 1

1

更改

  zoom: 10

到一个较低的数字 - 较低的数字等于较小的缩放。

尝试:zoom: 5

缩放级别 10 的示例:

JSFiddle of Zoom 10

现在缩放级别 5:

JSFiddle of Zoom 5

于 2013-10-03T12:40:58.553 回答