2014-09-10 64 views
2

我已经能够在本地主机上部署谷歌地图,它加载所有坐标成功。 但是,当我上传相同的代码到我的服务器,它完全无法加载。我尽我所能,真的在这里迷路了。谷歌地图加载在本地主机上,但无法加载在线服务器

<html> 
<head> 

<script type='text/javascript' src='jquery-1.6.2.min.js'></script> 
<script type='text/javascript' src='jquery-ui-1.8.14.custom.min.js'></script> 

<style> 

    BODY {font-family : Verdana,Arial,Helvetica,sans-serif; color: #000000; font-size : 13px ; } 

    #map_canvas { width:100%; height: 100%; z-index: 0; } 
</style> 
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false" /></script> 

<script type='text/javascript'> 
jQuery(document).ready(function($){ 
     function closeInfos(){ 
      if(infos.length > 0){ 
       infos[0].set("marker",null); 
       infos[0].close(); 
       infos.length = 0; 
      } 
     } 

    //Get data, and replace it on the form 
    var geocoder; 
    var map; 
    var markersArray = []; 
    var infos = []; 

    geocoder = new google.maps.Geocoder(); 
    var myOptions = { 
      zoom: 9, 
      mapTypeId: google.maps.MapTypeId.ROADMAP 
     } 
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);  

    function deleteMarkers() { 
     for (var i = 0; i < markersArray.length; i++) { 
     markersArray[i].setMap(null); 
     } 

     markersArray = []; 
    } 

setInterval(function(){ 
    $.get('ajax_gp_gps.php', function(data){   
    var bounds = new google.maps.LatLngBounds(); 
    var encodedString; 
    var stringArray = []; 
    encodedString = data; 
    stringArray = encodedString.split("****"); 

    var x; 
    for (x = 0; x < stringArray.length; x = x + 1) 
    { 
     var addressDetails = []; 
     var marker; 
     addressDetails = stringArray[x].split("&&&"); 

     var lat = new google.maps.LatLng(addressDetails[1], addressDetails[2]); 
     //alert(image + " " + addressDetails[1]); 
     marker = new google.maps.Marker({ 
      map: map, 
      position: lat, 
      content: addressDetails[0] 
     }); 
     markersArray.push(marker); 
     google.maps.event.addListener(marker, 'click', function() { 
      closeInfos(); 
      var info = new google.maps.InfoWindow({content: this.content}); 
      // where I have added .html to the marker object. 
      //infowindow.setContent(marker.html); 
      info.open(map,this); 
      infos[0]=info; 
     }); 
     bounds.extend(lat); 
    } 

    map.fitBounds(bounds); 


    }); 
},1000); 

});  
</script> 

</head> 
<body> 

<?php include_once("ajax_gp_gps.php"); ?> 

<div id='input'> 
    <input type="hidden" id="encodedString" name="encodedString" value="<?php echo $encodedString; ?>"> 
</div> 
<div id="map_canvas"></div> 

</body> 
</html> 
+0

确保你已经更新了你的路径(对于你的资产> jquery和jquery-ui) – 2014-09-10 14:11:27

+0

所有的路径都已到位,我认为它可能来自我可能在看的东西...只是可以放一个手指在上面。 – decongh 2014-09-10 14:32:40

+0

你可以检查铬/火狐工具(F12),看看是否有什么东西? – 2014-09-10 14:53:14

回答

0

如果您的在线域名有权访问或不需要,您需要检查Google API。

+0

这些是我的脚本 - \t ,我在想它可能是我的连接脚本... – decongh 2014-09-10 18:05:23

+0

感谢您的时间伙计,它的连接脚本MySQL数据库。我改变了它,每件事情都很好。谢谢。我是否必须将此问题标记为已解决? – decongh 2014-09-11 10:05:11

+0

所以实际上它从来没有与谷歌API的问题。我认为你至少应该为我的答案投票。 – 2014-09-11 12:15:58

相关问题