Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/242.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

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
通过PHP include语句嵌入Googlemap_Php_Google Maps_Php Include - Fatal编程技术网

通过PHP include语句嵌入Googlemap

通过PHP include语句嵌入Googlemap,php,google-maps,php-include,Php,Google Maps,Php Include,我创建了一个自定义google地图来显示我的业务分支,它存储在一个名为[map locations].php的文件中 当我在浏览器中打开这个文件时,该文件显示得非常完美,但是如果我尝试使用include语句包含这个php文件,它根本不会显示 我曾尝试将代码直接复制粘贴到我的网站页面上,我希望代码能够显示出来,但也没有显示出来 我更希望能够通过include语句显示地图,但现在只显示就好了 <meta name="viewport" content="initial-scale=1.

我创建了一个自定义google地图来显示我的业务分支,它存储在一个名为[map locations].php的文件中

当我在浏览器中打开这个文件时,该文件显示得非常完美,但是如果我尝试使用include语句包含这个php文件,它根本不会显示

我曾尝试将代码直接复制粘贴到我的网站页面上,我希望代码能够显示出来,但也没有显示出来

我更希望能够通过include语句显示地图,但现在只显示就好了

    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <style type="text/css">
      html { height: 100% }
      body { height: 100%; margin: 0; padding: 0 }
      .wrap { max-width: 75em; min-height: 40em; height:600px; width:500px;   margin: 0 auto; padding-top: 2.5%;}
      #map-canvas { height: 90%; }
    </style>
    <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=true">
    </script>
    <script type="text/javascript">
      var map;
      var centerPos = new google.maps.LatLng(51.6491587,0.0386048);
      var zoomLevel = 11;


      function LogoControl(controlDiv, map) { 
  controlDiv.style.padding = '5px';
  var controlUI = document.createElement('div');
  controlUI.style.backgroundImage = 'url(http://www.1stopinstruction.com/media/images/logos/1stop/googlemap-title.gif)';
  controlUI.style.width = '275px';
  controlUI.style.height = '65px';
  controlUI.style.cursor = 'pointer';
  controlUI.title = 'Click to set the map to Home';
  controlDiv.appendChild(controlUI);
  google.maps.event.addDomListener(controlUI, 'click', function() {
    map.setCenter(centerPos)
    map.setZoom(zoomLevel)
  });

}

      function initialize() {
        var mapOptions = {
          center: centerPos,
          zoom: zoomLevel
        };
        map = new google.maps.Map( document.getElementById("map-canvas"), mapOptions );
            var locations = [
  ['East London - Ilford (Fairlop Powerleague)', 51.598589, 0.101594],
  ['North London - Tottenham (Frederick Knight Sports Ground)',51.607052, -0.054270],
  ['Highams Park - Chingford (LGV & PCV Only)',51.609685, -0.005183],
  ['North Weald Airfield (kneedown & Wheelie Only)',51.717709, 0.160214],
  ['Office Address',51.572126, 0.106147]
]
var image = "http://www.1stopinstruction.com/media/images/logos/1stop/googlemap-icon.gif";

 logoControlDiv = document.createElement('div');
var logoControl = new LogoControl(logoControlDiv, map);

logoControlDiv.index = 1;
map.controls[google.maps.ControlPosition.TOP_CENTER].push(logoControlDiv);


for (i = 0; i < locations.length; i++) {  
  marker = new google.maps.Marker({
    position: new google.maps.LatLng(locations[i][1], locations[i][2]),
    title: locations[i][0],
    map: map,
    icon: image
  });
}
      }
      google.maps.event.addDomListener(window, 'load', initialize);
    </script>

  <body>
  <div class="wrap">
    <div id="map-canvas"></div>
  </div>
  </body>

问题是javascrip代码是在DOM完全充电之前执行的。将您的javascript代码放在文档底部的。。。但是在body标签内部,使用jQuery是一个选项?您是否在浏览器级别检查了HTML以查看是否创建了地图?如果它不在那里,你的问题是包含。如果有,问题在于包含的内容。