我有一张用markerClusterer显示标记的地图。
在普通视图中,所有操作都很好,但是在全屏模式下,单击集群运行"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>当运行“triggerClusterClick”中的“markerclusterer.js”中的限界时,会发生缩放而不是放大:
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());
}
};有人知道发生了什么吗?
PS:对全屏的更改使用"fullscreenControl“(在选项图中启用)
带问题的示例:小提琴
发布于 2016-12-01 17:55:14
当在div地图的高度中使用'%测量‘时,就会出现这个问题
我是这样解决问题的:
html, body {
height: 100%;
width: 100%;
margin: 0px;
padding: 0px
}溶液样本:小提琴
https://stackoverflow.com/questions/40902393
复制相似问题