1
我有一個地圖顯示標記與markerClusterer。谷歌地圖:全屏+ fitBounds不適合邊界
在普通視圖中一切正常,但在全屏模式下,羣集上的點擊運行「fitBounds」,並且縮放沒有正確更改(縮小而不是縮放)。
代碼:
var mapOptions = {
zoom: 17,
minZoom: 4,
maxZoom: 20,
center: {lat: 0, lng: 0},
fullscreenControl: true
}
var mcOptions = {
gridSize: 20,
styles: clusterStyles,
maxZoom: 20
};
var bounds = new google.maps.LatLngBounds();
function initialize(itensJSON){
var map = new google.maps.Map(document.getElementById("map"), mapOptions);
$.each(itensJSON, function (i, item) {
var marker = new google.maps.Marker({
position: item.location,
id: item.id
});
markers.push(marker);
bounds.extend(marker.getPosition());
});
map.fitBounds(bounds);
markerClusterer = new MarkerClusterer(map, markers, mcOptions);
}
HTML:
<div id="map_container" style="position: absolute; width: 100%; height: 80%;">
<div id="map" style="width: 100%; height: 100%">
</div>
</div>
縮小發生,而不是在放大,運行在markerclusterer.js的 'triggerClusterClick' 的fitbounds時:
ClusterIcon.prototype.triggerClusterClick = function(event) {
var markerClusterer = this.cluster_.getMarkerClusterer();
// Trigger the clusterclick event.
google.maps.event.trigger(markerClusterer, 'clusterclick', this.cluster_, event);
if (markerClusterer.isZoomOnClick()) {
// Zoom into the cluster.
this.map_.fitBounds(this.cluster_.getBounds());
}
};
有誰知道發生了什麼? (在選項映射啓用)的變化,以全屏幕與「fullscreenControl」製成
樣品與該問題::
PS fiddle
請提供一個演示此問題的[mcve]。 – geocodezip