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