我的地图脚本无效。我在两个单独的页面上有两个地图,他们最初工作,但现在我已经做了一些CSS更改(与地图无关),它不再显示。当我在浏览器中检查它时,容器仍在那里,但它不会出现。这是我的测试服务器www.trutattoo.amdesigns.studio
这是我的api密钥的脚本。我在两个页面上都有它。
Here it is on my html page
<!-- ============ Google Map - START ============ -->
<div id="map"></div>
<!-- ============ Google Map - END ============ -->
And this is the jquery
function init() {
// Google Map options
// For more options see: https://developers.google.com/maps/documentation/javascript/reference#MapOptions
var mapOptions = {
draggable : isMobile() ? false : true,
streetViewControl : false,
disableDoubleClickZoom : true,
scrollwheel : false,
zoom : mapData.zoom,
center : new google.maps.LatLng(33.009378,-96.842931),
styles: [{"featureType":"administrative","elementType":"labels.text.fill","stylers":[{"color":"#444444"}]},{"featureType":"administrative.locality","elementType":"geometry","stylers":[{"visibility":"on"},{"color":"#cfc8be"}]},{"featureType":"landscape","elementType":"all","stylers":[{"color":"#f2f2f2"}]},{"featureType":"poi","elementType":"all","stylers":[{"visibility":"off"}]},{"featureType":"road","elementType":"all","stylers":[{"saturation":-100},{"lightness":45}]},{"featureType":"road.highway","elementType":"all","stylers":[{"visibility":"simplified"}]},{"featureType":"road.arterial","elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"featureType":"transit","elementType":"all","stylers":[{"visibility":"off"}]},{"featureType":"water","elementType":"all","stylers":[{"color":"#cfc8be"},{"visibility":"on"}]}]
},
// Create the Google Map using the map container and options defined above
map = new google.maps.Map(document.getElementById('map'), mapOptions);
var marker = new google.maps.Marker({
position : mapOptions.center: {lat:-34.397, lgn: 150.644},
map : map,
icon : mapData.marker
});
}
答案 0 :(得分:0)
尝试更改
var marker = new google.maps.Marker({
position : mapOptions.center: {lat:-34.397, lgn: 150.644},
map : map,
icon : mapData.marker
});
到
var marker = new google.maps.Marker({
position : mapOptions.center,
map : map,
icon : mapData.marker
});