如何让Google地图调整大小并以电话设备为中心?
我正在使用WordPress和http://gmap3.net/。
我已经尝试过在WordPress.org上找到的一些解决方案
有人可以帮忙吗?
$(".gmap").gMap({
controls: {
panControl: false,
zoomControl: false,
mapTypeControl: false,
scaleControl: false,
streetViewControl: false,
draggable: true,
overviewMapControl: false
},
scrollwheel: false,
draggable: false,
markers: [{
latitude: 41.62552,
longitude: -81.44203
}],
icon: {
image: 'img/pin',
iconsize: [32, 48],
iconanchor: [16, 24],
infowindowanchor: [0, 0]
},
latitude: 41.62552,
longitude: -81.44203,
zoom: 12
})
var myGmap = $('.gmap').data('gMap.reference');
var styles = [{
"featureType": "all",
"elementType": "all",
"stylers": [{
"invert_lightness": true
}, {
"saturation": 10
}, {
"lightness": 40
}, {
"gamma": 0.6
}, {
"hue": "#1079bf"
}]
}, {
"featureType": "road.highway",
"elementType": "geometry",
"stylers": [{
"color": "#99CC66"
}]
}, {
"featureType": "administrative",
"elementType": "all",
"stylers": [{
"color": "#ffffff"
}, {
"visibility": "simplified"
}]
}]
var styledMap = new google.maps.StyledMapType(
styles, {
name: "Styled Map"
}
);
myGmap.mapTypes.set('map_style', styledMap);
myGmap.setMapTypeId('map_style');
});
答案 0 :(得分:0)
插件可能有所不同,但对于谷歌地图,如果你在初始化函数中放置这样的东西,它会在浏览器调整大小时居中。
google.maps.event.addDomListener(window, 'resize', function () {
map.setCenter({ lat: 41.62552, lng: -81.44203 });
});