电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

使用javaScript从高德地图获取数据VIP免费

使用javaScript从高德地图获取数据_第1页
1/8
使用javaScript从高德地图获取数据_第2页
2/8
使用javaScript从高德地图获取数据_第3页
3/8
使用javaScript从高德地图获取数据12308047姚逸璠A、工具:VisualStudio2010B、语言:HTML、javaScriptC、实现流程:1、在visualstudio中,点击文件->新建->网站,得到下图:选择:ASP.NET空网站。2、在“设计”视图下,使用工具箱分别添加一个“div容器”,与一个“Button”,如下:3、转到“源”视图,为Button添加监听器onclick,并附上javascript代码,代码如下所示(注意需要填入申请的高德map的key,以及构造map时使用我们刚刚添加的容器)关键字查询body{margin:0;height:100%;width:100%;position:absolute;font-size:12px;}#mapContainer{position:absolute;top:0;left:0;right:0;bottom:0;}#mapSearch1{position:absolute;top:0;left:100;pageIndex:1;}
关键词搜索varmap=newAMap.Map("mapContainer",{resizeEnable:true});varmarker=newArray();varwindowsArr=newArray();//基本地图加载functionplaceSearch(){varMSearch;AMap.service(["AMap.PlaceSearch"],function(){MSearch=newAMap.PlaceSearch({//构造地点查询类pageSize:10,pageIndex:1,city:"020"//城市});//关键字查询MSearch.search('白云宾馆',function(status,result){if(status==='complete'&&result.info==='OK'){keywordSearch_CallBack(result);}else{alert("Failed");}});});}//placeSearch();//添加marker&infowindowfunctionaddmarker(i,d){varlngX=d.location.getLng();varlatY=d.location.getLat();varmarkerOption={map:map,icon:"http://webapi.amap.com/images/"+(i+1)+".png",position:newAMap.LngLat(lngX,latY),topWhenMouseOver:true};varmar=newAMap.Marker(markerOption);marker.push(newAMap.LngLat(lngX,latY));varinfoWindow=newAMap.InfoWindow({content:"

"+(i+1)+"."+d.name+"

"+TipContents(d.type,d.address,d.tel),size:newAMap.Size(300,0),autoMove:true,offset:newAMap.Pixel(0,-20)});windowsArr.push(infoWindow);varaa=function(e){infoWindow.open(map,mar.getPosition());};AMap.event.addListener(mar,"mouseover",aa);}//回调函数functionkeywordSearch_CallBack(data){varresultStr="";varpoiArr=data.poiList.pois;varresultCount=poiArr.length;for(vari=0;i"+"

名称:"+poiArr[i].name+"

";resultStr+=TipContents(poiArr[i].type,poiArr[i].address,poiArr[i].tel)+"
";addmarker(i,poiArr[i]);}map.setFitView();}functionTipContents(type,address,tel){//窗体内容if(type==""||type=="undefined"||type==null||type=="undefined"||typeoftype=="undefined"){type="暂无";}if(address==""||address=="undefined"||address==null||address=="undefined"||typeofaddress=="undefined"){address="暂无";}if(tel==""||tel=="undefined"||tel==null||tel=="undefined"||typeofaddress=="tel"){tel="暂无";}varstr="地址:"+address+"
电话:"+tel+"
类型:"+type;returnstr;}functionopenMarkerTipById1(pointid,thiss){//根据id打开搜索结果点tipthiss.style.background='#CAE1FF';windowsArr[p...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

使用javaScript从高德地图获取数据

您可能关注的文档

文章天下+ 关注
实名认证
内容提供者

各种文档应有尽有

相关文档

热门下载

相关标签

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部