Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.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 夜间地球异步负荷图_Javascript_Google Maps_Google Maps Api 3 - Fatal编程技术网

Javascript 夜间地球异步负荷图

Javascript 夜间地球异步负荷图,javascript,google-maps,google-maps-api-3,Javascript,Google Maps,Google Maps Api 3,我想在通过JS API 3加载时使用此自定义映射: 我不知道如何使用提供的API代码addLayersToMap(map),在文档中的任何地方都找不到该函数。我相信这和在地图上调用这个函数一样简单,但这似乎并没有让我有任何进展 以下是我的嵌入代码: <script type="text/javascript"> function initialize() { var mapOptions = {

我想在通过JS API 3加载时使用此自定义映射:

我不知道如何使用提供的API代码addLayersToMap(map),在文档中的任何地方都找不到该函数。我相信这和在地图上调用这个函数一样简单,但这似乎并没有让我有任何进展

以下是我的嵌入代码:

        <script type="text/javascript"> 
            function initialize() {
              var mapOptions = {
                zoom: 14,
                center: new google.maps.LatLng(32.26555,-110.961386)
              };

              var map = new google.maps.Map(document.getElementById('map-canvas'),
                mapOptions);

              var mapsEngineLayer = new google.maps.visualization.MapsEngineLayer({
                layerId: '06673056454046135537-08896501997766553811',
                map: map
              });
            }
            function addLayersToMap(map) {
              // Handles to the layers created.  var layers = [];
              var layerKeys = [
              ""
              ];

              for (var i = 0; i < layerKeys.length; ++i) {
                layers.push(new google.maps.visualization.MapsEngineLayer({
                  mapId: "10446176163891957399-13737975182519107424-4",
                  layerKey: layerKeys[i],
                  map: map
                }));
              }
              return layers;
            }

            function loadScript()
            {
                var script = document.createElement("script");
                script.type = "text/javascript";
                script.src = "http://maps.googleapis.com/maps/api/js?key=AIzaSyDOkhCBaoEKOhnpEJorFi83JSb0vIEkRg4&sensor=false&callback=initialize";
                document.body.appendChild(script);
            }
            window.onload = loadScript();
        </script>

函数初始化(){
变量映射选项={
缩放:14,
中心:新google.maps.LatLng(32.26555,-110.961386)
};
var map=new google.maps.map(document.getElementById('map-canvas'),
地图选项);
var mapsEngineLayer=新建google.maps.visualization.mapsEngineLayer({
分层:“06673056454046135537-08896501997766553811”,
地图:地图
});
}
函数addLayersToMap(映射){
//创建的层的句柄。var layers=[];
变量layerKeys=[
""
];
对于(变量i=0;i
使用API文档中的数据解决了这个问题。只需拉出其中一个图层并替换地图ID。将其放入并放入地图画布div,您将成为金色的

<script src="https://maps.googleapis.com/maps/api/js?sensor=false&libraries=visualization"></script>
<script>
    var map;
    function initialize() {
      var mapOptions = {
        center: new google.maps.LatLng(42, -99),
        zoom: 5
      };
      map = new google.maps.Map(document.getElementById('map-canvas'),
        mapOptions);

      var mapsEngineLayer2 = new google.maps.visualization.MapsEngineLayer({
        mapId: '10446176163891957399-13737975182519107424-4',
        layerKey: 'layer_00001'
      });
      mapsEngineLayer2.setMap(map);
    }

    google.maps.event.addDomListener(window, 'load', initialize);
</script>

var映射;
函数初始化(){
变量映射选项={
中心:新google.maps.LatLng(42,-99),
缩放:5
};
map=new google.maps.map(document.getElementById('map-canvas'),
地图选项);
var mapsEngineLayer2=新建google.maps.visualization.MapsEngineLayer({
mapId:'10446176163891957399-13737975182519107424-4',
layerKey:“layer_00001”
});
mapsEngineLayer2.setMap(地图);
}
google.maps.event.addDomListener(窗口“加载”,初始化);