Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用google地图和require js异步插件不起作用_Javascript_Jquery_Google Maps_Google Maps Api 3_Requirejs - Fatal编程技术网

Javascript 使用google地图和require js异步插件不起作用

Javascript 使用google地图和require js异步插件不起作用,javascript,jquery,google-maps,google-maps-api-3,requirejs,Javascript,Jquery,Google Maps,Google Maps Api 3,Requirejs,控制台的输出当我尝试从main.js调用map.getZoom()时,控制台的输出似乎表明地图已加载但未显示: -34.397,150.644 maploader.js:19 the map was loaded maploader.js:11 The map is zoomed to 4 maploader.js:13 From main main.js:22 4 当我尝试使用requirejs模块显示地图时,地图不会显示,如下所示: gmaps.js maploader.js

控制台的输出当我尝试从
main.js
调用
map.getZoom()
时,控制台的输出似乎表明地图已加载但未显示:

 -34.397,150.644 maploader.js:19
 the map was loaded maploader.js:11
 The map is zoomed to 4 maploader.js:13
 From main main.js:22
 4 
当我尝试使用
requirejs
模块显示地图时,地图不会显示,如下所示:

gmaps.js maploader.js main.js 这是我的目录结构:

~/Desktop/maps/modules_test $ ls -LR
.:
css  index.html  scripts

./css:
 init.css

./scripts:
 gmaps.js  lib  main.js  maploader.js

./scripts/lib:
 jquery.min.js  plugins  require.js

./scripts/lib/plugins:
 async.js   font.js  image.js  mdown.js  propertyParser.js
 depend.js  goog.js  json.js   noext.js
更新: 这也不起作用,更糟糕的是,它甚至不打印我的控制台日志

require(['./gmaps','./maploader'],function(gmaps,map){
    var initialize=function()
    {
        var myDiv=document.getElementById('map-canvas');
        var center=map.createLatLng(-34.397, 150.644);
        var myMap=map.fetchMap(myDiv,center,4);
        console.log('From main');
        console.log(''+myMap.getZoom());
    };

    gmaps.event.addDomListener(window,'load',initialize);
}); 

函数
createLatLng()
不返回中心值:

        createLatLng:function(lat,lng)
        {
            var p=new gmaps.LatLng(lat,lng);
            console.log(p.lat()+','+p.lng());
        }

没有
返回p声明。

你不知道我离目标有多远,我只是在要求后检查了整个文档的html,gmaps修改了它以寻找线索。谢谢
~/Desktop/maps/modules_test $ ls -LR
.:
css  index.html  scripts

./css:
 init.css

./scripts:
 gmaps.js  lib  main.js  maploader.js

./scripts/lib:
 jquery.min.js  plugins  require.js

./scripts/lib/plugins:
 async.js   font.js  image.js  mdown.js  propertyParser.js
 depend.js  goog.js  json.js   noext.js
require(['./gmaps','./maploader'],function(gmaps,map){
    var initialize=function()
    {
        var myDiv=document.getElementById('map-canvas');
        var center=map.createLatLng(-34.397, 150.644);
        var myMap=map.fetchMap(myDiv,center,4);
        console.log('From main');
        console.log(''+myMap.getZoom());
    };

    gmaps.event.addDomListener(window,'load',initialize);
}); 
        createLatLng:function(lat,lng)
        {
            var p=new gmaps.LatLng(lat,lng);
            console.log(p.lat()+','+p.lng());
        }