-1
我想在一個頁面上有多個谷歌地圖。在同一個頁面上的多個谷歌地圖
我有這個代碼,但我不知道我該怎麼做。
必須添加什麼?
我想要其他具有相同樣式的地圖。
還有一個問題是,谷歌地圖不加載全部
任何人都可以幫我嗎?
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;
所有地圖實例具有相同的ID,所以你只CANT看到一張地圖(風格)。對於每個你想要的地圖,給出適當的地圖選項。 – Bene
不允許你添加更多的畫布,並用正確的ID多次調用這個? var map = new google.maps.Map(document.getElementById('!! here your differenty id !!!'), mapOptions); – Yeronimo
貝恩你可以給一個樣品,以相同的風格的地圖? – nikospap