我想在一页上有多个谷歌地图。
我有这个代码,但我不知道我该怎么做。
必须添加什么?
我想要其他具有相同样式的地图。
另一个问题是谷歌地图没有加载完整
谁能帮我?
function initialize() {
var styles = [
{
featureType: 'water',
elementType: 'all',
stylers: [
{ hue: '#E6E6E6' },
{ saturation: -100 },
{ lightness: 59 },
{ visibility: 'on' }
]
},{
featureType: 'landscape.natural',
elementType: 'all',
stylers: [
{ hue: '#999999' },
{ saturation: -100 },
{ lightness: -37 },
{ visibility: 'on' }
]
},{
featureType: 'road',
elementType: 'all',
stylers: [
{ hue: '#4C4C4C' },
{ saturation: -100 },
{ lightness: -53 },
{ visibility: 'simplified' }
]
},{
featureType: 'landscape.man_made',
elementType: 'all',
stylers: [
{ hue: '#ffffff' },
{ saturation: -100 },
{ lightness: 100 },
{ visibility: 'on' }
]
},{
featureType: 'road.highway',
elementType: 'all',
stylers: [
{ hue: '#bfbfbf' },
{ saturation: -100 },
{ lightness: 30 },
{ visibility: 'on' }
]
},{
featureType: 'road.arterial',
elementType: 'labels',
stylers: [
{ hue: '#bfbfbf' },
{ saturation: -100 },
{ lightness: -3 },
{ visibility: 'simplified' }
]
},{
featureType: 'road.local',
elementType: 'geometry',
stylers: [
{ hue: '#f1f1f1' },
{ saturation: -100 },
{ lightness: -5 },
{ visibility: 'simplified' }
]
},{
featureType: 'poi',
elementType: 'all',
stylers: [
{ hue: '#e6e6e6' },
{ saturation: -100 },
{ lightness: 55 },
{ visibility: 'on' }
]
},{
featureType: 'poi.park',
elementType: 'all',
stylers: [
{ hue: '#d0d0d0' },
{ saturation: -100 },
{ lightness: 16 },
{ visibility: 'on' }
]
}
];
var mapOptions = {
mapTypeControlOptions: {
mapTypeIds: [ 'Styled']
},
center: new google.maps.LatLng(37.96112215672197, 23.72348675727846),
zoom: 16,
mapTypeId: 'Styled'
};
var map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
var styledMapType = new google.maps.StyledMapType(styles, { name: 'Styled' });
map.mapTypes.set('Styled', styledMapType);
}
function loadScript() {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&' +
'callback=initialize';
document.body.appendChild(script);
}
window.onload = loadScript;