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
谷歌地图API在我的网站上不起作用 var simplerweb=new google.maps.LatLng(55.977046,-3.197118); var标记; var映射; 函数初始化(){ 变量myOptions={ 中心:新google.maps.LatLng(55.977046,-3.197118), disableDefaultUI:true, 缩放:15, 滚轮:错误, 导航控制:错误, mapTypeControl:false, scaleControl:false, 可拖动:错误, mapTypeId:google.maps.mapTypeId.ROADMAP }; var map=new google.maps.map(document.getElementById(“map_canvas”), 肌肽); marker=新的google.maps.marker({ 地图:地图, 真的, 动画:google.maps.animation.DROP, 职位:andrewmorris, 图标:'http://www.andrewsmorris.co.uk/images/point.png' }); google.maps.event.addListener(标记'click',toggleBounce); } 函数toggleBounce(){ if(marker.getAnimation()!=null){ marker.setAnimation(null); }否则{ setAnimation(google.maps.Animation.BOUNCE); } }_Api_Google Maps - Fatal编程技术网

谷歌地图API在我的网站上不起作用 var simplerweb=new google.maps.LatLng(55.977046,-3.197118); var标记; var映射; 函数初始化(){ 变量myOptions={ 中心:新google.maps.LatLng(55.977046,-3.197118), disableDefaultUI:true, 缩放:15, 滚轮:错误, 导航控制:错误, mapTypeControl:false, scaleControl:false, 可拖动:错误, mapTypeId:google.maps.mapTypeId.ROADMAP }; var map=new google.maps.map(document.getElementById(“map_canvas”), 肌肽); marker=新的google.maps.marker({ 地图:地图, 真的, 动画:google.maps.animation.DROP, 职位:andrewmorris, 图标:'http://www.andrewsmorris.co.uk/images/point.png' }); google.maps.event.addListener(标记'click',toggleBounce); } 函数toggleBounce(){ if(marker.getAnimation()!=null){ marker.setAnimation(null); }否则{ setAnimation(google.maps.Animation.BOUNCE); } }

谷歌地图API在我的网站上不起作用 var simplerweb=new google.maps.LatLng(55.977046,-3.197118); var标记; var映射; 函数初始化(){ 变量myOptions={ 中心:新google.maps.LatLng(55.977046,-3.197118), disableDefaultUI:true, 缩放:15, 滚轮:错误, 导航控制:错误, mapTypeControl:false, scaleControl:false, 可拖动:错误, mapTypeId:google.maps.mapTypeId.ROADMAP }; var map=new google.maps.map(document.getElementById(“map_canvas”), 肌肽); marker=新的google.maps.marker({ 地图:地图, 真的, 动画:google.maps.animation.DROP, 职位:andrewmorris, 图标:'http://www.andrewsmorris.co.uk/images/point.png' }); google.maps.event.addListener(标记'click',toggleBounce); } 函数toggleBounce(){ if(marker.getAnimation()!=null){ marker.setAnimation(null); }否则{ setAnimation(google.maps.Animation.BOUNCE); } },api,google-maps,Api,Google Maps,所以我不明白为什么这在我的新网站上不起作用,在我的旧网站上效果很好 我在一个叫map_canvas的部门工作 应该行的,对吧? Google maps API设置为允许从该URL进行推荐。只要您有正确的密钥,它就可以正常工作 您是否仔细检查了是否在html正文中调用了initialize() <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=MYKEYHERE&

所以我不明白为什么这在我的新网站上不起作用,在我的旧网站上效果很好

我在一个叫map_canvas的部门工作

应该行的,对吧?
Google maps API设置为允许从该URL进行推荐。

只要您有正确的密钥,它就可以正常工作

您是否仔细检查了是否在html正文中调用了initialize()

 <script type="text/javascript"
      src="http://maps.googleapis.com/maps/api/js?key=MYKEYHERE&sensor=false">
    </script>
    <script type="text/javascript">



var simplerweb = new google.maps.LatLng(55.977046,-3.197118);
var marker;
var map;






      function initialize() {
        var myOptions = {
          center: new google.maps.LatLng(55.977046,-3.197118),  
          disableDefaultUI: true,
          zoom: 15,
           scrollwheel: false,
    navigationControl: false,
    mapTypeControl: false,
    scaleControl: false, 
    draggable: false,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        var map = new google.maps.Map(document.getElementById("map_canvas"),
            myOptions);
  marker = new google.maps.Marker({
    map:map,
    draggable:true,
    animation: google.maps.Animation.DROP,
    position: andrewmorris,
    icon: 'http://www.andrewsmorris.co.uk/images/point.png' 
  });
  google.maps.event.addListener(marker, 'click', toggleBounce);
}





function toggleBounce() {

  if (marker.getAnimation() != null) {
    marker.setAnimation(null);
  } else {
    marker.setAnimation(google.maps.Animation.BOUNCE);
  }
}


    </script>


此外,指向标记图像的链接已断开。

啊,是的,我错过了onload调用!谢谢
<body onload="initialize()">
    <div id="map_canvas" style="width:100%; height:100%"></div>
</body>