我目前正在嘗試使用require.js模塊定義和依賴關係處理程序加載Google地圖庫及其擴展RichMarker。Require.js問題同時加載Google地圖和它的Richmarker擴展
我已經宣佈的路徑既谷歌地圖模塊和擴展類似以下內容:
"gmaps": "modules/google_maps",
"richmarker": "vendor/google/maps/richmarker.min"
的GOOGLE_MAPS模塊看上去就像
define('gmaps', ['async!http://maps.googleapis.com/maps/api/js?key=mykey&sensor=true'],
function(){
return window.google.maps;
});
最後,該模塊消耗google地圖庫和advancedMarker擴展定義如下:
define(['common', 'gmaps','jquery','jqueryui', 'bootstrap',"vendor/google/maps/clusterer.min", "tmp/clusteringData", "richmarker"],
function(common, gmaps){
然而,GoogleMap的正確inits onload事件,但我得到的錯誤關於我的控制檯richmarker擴展:
Uncaught ReferenceError: google is not defined richmarker.min.js:1
Uncaught ReferenceError: RichMarker is not defined google.init.js:267
我在哪裏我做錯了?謝謝您的幫助。
我不認爲這適用於異步require.js插件。 –
即使當我映射到沒有異步的本地路徑時,這也不適用於我。 – pacman
也不適用於我 – tibalt