財產「MAXZOOM」我有選擇谷歌地圖對象:谷歌地圖API的JS - MarkerClusterer - 不能讀取的不確定
$(document).ready(function() {
var mapOptions = {
zoom: 4,
minZoom: 3,
maxZoom: 12,
center: new google.maps.LatLng(39.484973, -0.364126),
mapTypeControl: false,
streetViewControl: false
};
var mapElement = document.getElementById('#map');
map = new google.maps.Map(mapElement, mapOptions);
markers = [...];
markerCluster = new MarkerClusterer(map, markers, {
averageCenter: true,
styles: [{
url: '/cluster.png',
width: 64,
height: 64,
textColor: 'white',
backgroundPosition: 'center'
}]
});
...
}
現在初始化地圖後,我想通過運行改變縮放級別:
var location = ...
map.setCenter(location); // works fine
map.setZoom(7);`,
,但我在控制檯得到一個錯誤:
Uncaught TypeError: Cannot read property 'maxZoom' of undefined
at Ag.<anonymous> (markerclusterer.js:163)
at Object._.z.trigger (js?key=AIzaSyBpuEnTxOHtdmlMllM_Qd2SL_Q2t45o3_0:99)
at Hb (js?key=AIzaSyBpuEnTxOHtdmlMllM_Qd2SL_Q2t45o3_0:38)
at Ag._.k.set (js?key=AIzaSyBpuEnTxOHtdmlMllM_Qd2SL_Q2t45o3_0:101)
at Ag.setZoom (js?key=AIzaSyBpuEnTxOHtdmlMllM_Qd2SL_Q2t45o3_0:56)
at OfferMap.setBounds (offers_offer-map_1.js:1)
at HTMLDocument.<anonymous> (offers_trainee-offers_3.js:1)
at i (jquery.min.js:2)
at Object.fireWith [as resolveWith] (jquery.min.js:2)
at Function.ready (jquery.min.js:2)
任何人有任何想法是怎麼回事?
UPDATE
既然問題是因爲MarkerClusterer作爲@geocodezip在下面的評論中提到,這裏是我在加載腳本:
<script type="text/javascript" src="https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/markerclusterer.js"></script>
你有工作小提琴嗎? – Mazz
項目太複雜,無法複製爲小提琴,抱歉:/ –
您是否在'
'標籤之前或之後放置了js? – Mazz