老师怎么突然开始报错了,之前能运行的其它功能也开始报错了。
来源:8-11 自由编程
ssszz
2019-07-27 14:51:05
是因为这个key有时间限制吗? 之前我做成功的几个功能现在也不行了
4回答
你好同学,老师测试没有问题,可能是你那边的网络问题,可能波动大,或是其他问题,过段时间试试或者换个网络。
祝学习愉快,望采纳。
ssszz
提问者
2019-07-27
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>我的地图</title> <style type="text/css"> *{ margin: 0; padding: 0; } #container{ width: 100%; height: 100%; position: absolute; left: 0; top: 0; } .toolbar{ width: 370px; height: 380px; position: fixed; left: 20px; top: 20px; box-shadow: 1px 1px 3px #000; background-color: #fff; } .toolbar div span{ display: inline-block; width: 120px; text-align: right; } .toolbar input{ padding: 4px; } .toolbar .caption{ height: 50px; line-height: 50px; font-size: 25px; font-weight: bold; font-family: "黑体"; text-align: center; } .toolbar >div{ margin-bottom: 15px; height: 30px; } .toolbar >div a{ display: inline-block; width: 42px; height: 27px; line-height: 27px; text-align:center; text-decoration: none; color: #fff; background-color: #1fa4f0; font-size: 14px; position: relative; top: 1px; } .toolbar .changelimit{ width: 130px; height: 35px; line-height: 35px; background-color: #ccc; text-align: center; margin-left: 125px; cursor: pointer; } .toolbar p{ position: absolute; right: 5px; bottom: 5px; } </style> <script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=db78f529ccb566fcbe221b6402eacdde"></script> </head> <body> <div id="container"></div> <div class="toolbar" id="toolbar"> <div class="caption">工具栏</div> <div class="searchcity"> <span>搜索城市</span> <input type="text" id="searchcity-val"> <a href="javascript:void(0)" id="searchcity-btn">确定</a> </div> <div class="setzoom"> <span>设置显示级别</span> <input type="text" id="setzoom-val"> <a href="javascript:void(0)" id="setzoom-btn">确定</a> </div> <div class="changelimit" id="changelimit"> 解除范围限制 </div> <p>当前所在省/直辖市:<span id="mylocation"></span></p> </div> <script type="text/javascript"> var map = new AMap.Map('container'), myBounds=new AMap.Bounds([116.22422,39.813285],[116.567542,39.997639]); var searchCityVal=document.getElementById("searchcity-val"), searchCityBtn=document.getElementById("searchcity-btn"), setZoomVal=document.getElementById("setzoom-val"), setZoomBtn=document.getElementById("setzoom-btn"), changeLimit=document.getElementById("changelimit"), myLocation=document.getElementById("mylocation"); var chooseLimit=false; searchCityBtn.onclick=function(){ map.setCity(searchCityVal.value); } setZoomBtn.onclick=function(){ map.setZoom(parseInt(setZoomVal.value)); } map.on('moveend',function(){ map.getCity(function(info){ myLocation.innerHTML = info.province; }); }); // 设置右上角和左上角的坐标并添加范围限制器 map.setBounds(myBounds); var bjBounds=map.getBounds(); map.setLimitBounds(bjBounds); // console.log(bjBounds); changeLimit.onclick=function(){ chooseLimit=!chooseLimit; if(chooseLimit){ map.clearLimitBounds(); changeLimit.innerHTML="已解除范围限制"; }else{ map.setLimitBounds(bjBounds); map.setBounds(myBounds); changeLimit.innerHTML="解除范围限制"; } } // 定位鼠标点击的坐标 map.on('click',function(e){ map.setCenter([e.lnglat.lng,e.lnglat.lat]); }); </script> </body> </html>
这是我之前第一个自由编程写的,当时都可以运行地图的哪些功能,现在就突然不行了,我换了一个key也还是没能运行成功?
ssszz
提问者
2019-07-27
换了个key他又这样报错了,其他的地图也不行
好帮手慕夭夭
2019-07-27
你好同学,可能会存在失效的问题,建议同学重新申请一个试一下哦。
祝学习愉快,望采纳。
相似问题
回答 2