Map fitBounds()放大到数组中的最后一个标记

时间:2015-07-15 09:39:24

标签: javascript google-maps google-maps-api-3

我有一个google Maps bounds函数,运行如下:

function intializeCustom() {
    var map = new google.maps.Map(document.getElementById('map-dir'), {
        mapTypeId: google.maps.MapTypeId.ROADMAP,
    });
    for (i = 0; i < markers.length; i++) {
        var circle = new google.maps.Circle({
            map: map,
            radius: 3000,
            fillColor: '#2c3e50'
        });
        var bounds = new google.maps.LatLngBounds();
        var position = new google.maps.LatLng(markers[i][1], markers[i][2]);
        marker = new google.maps.Marker({
            position: position,
            map: map,
            title: markers[i][0]
        });
        circle.bindTo('center', marker, 'position');
        google.maps.event.addListener(circle, 'click', function(ev) {
            placeMarker(ev.latLng); //some function to place markers
        });
        bounds.extend(position);
        map.fitBounds(bounds);
    }
}

一切正常,除了界限。渲染上的地图放大markers数组中可用的最后一个标记。什么出了什么问题?

0 个答案:

没有答案