这是我负责会计地图的一块功能,实现定位,搜索,显示附近等,不多说直接上代码……
html:
<!doctype html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width"> <title>输入提示后查询</title> <script type="text/javascript" src="http://api.map.baidu.com/api?v=1.2"></script> <script src="../API/jquery-2.1.4.min.js"></script> <script type="text/javascript" src="http://webapi.amap.com/maps?v=1.3&key=ada0145080deff882d2a28e8af2047ad&plugin=AMap.Geocoder,AMap.Autocomplete,AMap.PlaceSearch,AMap.onComplete"></script> <link rel="stylesheet" type="text/css" href="../API/Api.css"> <script src="../API/Final.js"></script> </head> <body> <div class="box_dis"> <input class="myname" type="text" value="搜索地点" id="tipinput"/> <!--<input type="text" name="keyword" id="myname" class="myname" />--> </div> <div class="distance"> <div id="container"></div> </div> <div class="scroll" id="view"> <div id="panel"></div> <div id="panl"></div> </div> <div id="containe"></div> </body> </html>
JS:
/** * Created by lixuefeng on 16-1-25. */ window.onload = function () { input(); getLocation(); click(); search(); } function input() { function addListener(element, e, fn) { if (element.addEventListener) { element.addEventListener(e, fn, false); } else { element.attachEvent("on" + e, fn); } } var tipinput = document.getElementById("tipinput"); addListener(tipinput, "click", function () { tipinput.value = ""; //$('.myname').css('display', 'none'); }) addListener(tipinput, "blur", function () { tipinput.value ="搜索地点"; }) } var map, geolocation; //加载地图,调用浏览器定位服务 var autoOptions = { input: "tipinput" }; function click() { var clickEventListener = map.on('click', function (e) { var map = {latitude: e.lnglat.getLat(), longitude: e.lnglat.getLng()} localStorage.setItem("data", JSON.stringify(map)); near_address() }); } function search() { var auto = new AMap.Autocomplete(autoOptions); var placeSearch = new AMap.PlaceSearch({ map: map }); //构造地点查询类 AMap.event.addListener(auto, "select", select);//注册监听,当选中某条记录时会触发 function select(e) { placeSearch.setCity(e.poi.adcode); placeSearch.search(e.poi.name); //关键字查询查询 var poiArr = e.poi.name; localStorage.setItem("name", JSON.stringify(poiArr)); var geocoder = new AMap.Geocoder({ radius: 1000 //范围,默认:500 }); geocoder.getLocation(JSON.parse(localStorage.getItem("name")), function (status, result) { if (status === 'complete' && result.info === 'OK') { geocoder_CallBack(result); } }); } } function geocoder_CallBack(data) { var map = new BMap.Map("containe"); $(document).ready(function () { $("#panel").remove(); }); $("#panl").empty(); var geocode = data.geocodes; var dress = JSON.parse(localStorage.getItem("info")) var obj_info = {latitude: geocode[0].location.getLat(), longitude: geocode[0].location.getLng()}//gaiII localStorage.setItem("data", JSON.stringify(obj_info)); get_address() } function getLocation() { map = new AMap.Map('container', { resizeEnable: true }); if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition); } map.plugin('AMap.Geolocation', function () { geolocation = new AMap.Geolocation({ enableHighAccuracy: true,//是否使用高精度定位,默认:true timeout: 10000, //超过10秒后停止定位,默认:无穷大 buttonOffset: new AMap.Pixel(10, 10),//定位按钮与设置的停靠位置的偏移量,默认:Pixel(10, 20) zoomToAccuracy: true, //定位成功后调整地图视野范围使定位位置及精度范围视野内可见,默认:false buttonPosition: 'RB' }); map.addControl(geolocation); geolocation.getCurrentPosition(); }); $('.amap-logo').css('display', 'none'); $('.amap-copyright').css('display', 'none'); //$('.amap-geo').css('display', 'none'); } function showPosition(position) { var obj_info = {latitude: position.coords.latitude, longitude: position.coords.longitude}; console.log(obj_info.latitude) localStorage.setItem("info", JSON.stringify(obj_info)); displayPOI() } function near_address() { $(document).ready(function () { $("#panel").remove(); }); $("#panl").empty(); get_address() } var map = new BMap.Map("containe"); var mOption = { poiRadius: 2500, //半径为1000米内的POI,默认100米 numPois: 30 //列举出50个POI,默认10个 } map.centerAndZoom(mPoint, 15); map.enableScrollWheelZoom(); var myGeo = new BMap.Geocoder(); function get_address() { var mPoint = new BMap.Point(JSON.parse(localStorage.getItem("data")).longitude + 0.0065, JSON.parse(localStorage.getItem("data")).latitude + 0.0060); var myGeo = new BMap.Geocoder(); //创建地址解析实例 myGeo.getLocation(mPoint, function mCallback(rs) { var allPois = rs.surroundingPois; //获取全部POI(该点半径为100米内有6个POI点) allPois.forEach(function (place) { var html = "<div class='list' ><div class='site' id=" + place.title + ">" + place.title + "</div><div class='site_down'>" + place.address + "</div><span class='right'><img class='tex' src='../API/outstyle091100004.jpg' id=" + place.title + "></span></div></div>"; $("#panl").append(html); $($.parseHTML(html, document, true)).appendTo("body"); $(document).ready(function () { $('#' + place.title).click(function () { $('.tex').css('display', 'none'); $('#' + place.title).show(); }); }); }) }, mOption ); } function displayPOI() { var mPoint = new BMap.Point(JSON.parse(localStorage.getItem("info")).longitude + 0.0065, JSON.parse(localStorage.getItem("info")).latitude + 0.0060); ss(mPoint) } function ss(mPoint) { map.addOverlay(new BMap.Circle(mPoint, 0)); //添加一个圆形覆盖物 myGeo.getLocation(mPoint, function mCallback(rs) { var allPois = rs.surroundingPois; //获取全部POI(该点半径为100米内有6个POI点) allPois.forEach(function (place) { var html = "<div class='list' ><div class='site' id=" + place.title + ">" + place.title + "</div><div class='site_down'>" + place.address + "</div><span class='right'><img class='tex' src='../API/outstyle091100004.jpg' id=" + place.title + "></span></div></div>"; $("#panel").append(html); $(document).ready(function () { $('#' + place.title).click(function () { $('.tex').css('display', 'none'); $('#' + place.title).show(); }); }); }) }, mOption ); }
CSS:
.search{ height: 20px; width: 98%; margin-left: 12px; border:1px solid #e3e3e3; text-align: center; font-size: 5px; color:gray; } input { height: 20px; width: 98%; margin-left: 12px; border:1px solid #e3e3e3; padding:0px 16px; font-size: 5px; color:gray; } .myname { background:url(search64.png) center left no-repeat; background-size:15px 15px; } #containe{ display: none; } #mapContainer{ height: 300px; width: 100%; left: 0; right:0; bottom:0; } .map{ height: 300px; width: 100%; left: 0; right:0; bottom:0; } .scroll{ height: 325px; width: 100%; overflow-y:scroll; } /*div#view::-webkit-scrollbar {*/ /*background: transparent;*/ /*}*/ /*overflow:hidden*/ html { overflow: hidden; } body{ margin: 0; } .distance{ margin-top: 8px; margin-bottom: 4px; } .box_dis{ margin-top: 10px; } /*div#view:hover::-webkit-scrollbar {*/ /*background: lightyellow;*/ /*}*/ .list{ width: 98%; height: 50px; border-bottom:1px solid #e3e3e3; margin-left:25px; } /*.list{*/ /*width: 98%;*/ /*height:20px;*/ /*border-bottom:1px solid #e3e3e3;*/ /*margin-left:25px;*/ /*}*/ .site{ padding-top: 6px; /*width: 98%;*/ /*height: 50px;*/ /*border-bottom:1px solid #e3e3e3;*/ /*margin-left:25px;*/ } .site_down{ font-size: 10px; color:gray; padding-top: 1px; float: left; } .right{ float: right; margin-top: 0px; margin-right: 20px; } /*{*/ /*position: absolute;*/ /*top:0;*/ /*left: 0;*/ /*right:0;*/ /*bottom:0;*/ /*}*/ .tex{ height:20px; width: 20px; display: none; } .text{ height:15px; width: 15px; text-align: center; } .hide{ display: none; } ************ html, body { margin: 0; height: 100%; width: 100%; } #container { left: 0; right: 0; width: 100%; height: 300px; } .button-group { position: absolute; bottom: 20px; right: 20px; font-size: 12px; padding: 10px; } .button-group .button { height: 28px; line-height: 28px; background-color: #0D9BF2; color: #FFF; border: 0; outline: none; padding-left: 5px; padding-right: 5px; border-radius: 3px; margin-bottom: 4px; cursor: pointer; } .button-group .inputtext { height: 26px; line-height: 26px; border: 1px; outline: none; padding-left: 5px; padding-right: 5px; border-radius: 3px; margin-bottom: 4px; cursor: pointer; } /* .tip { position: absolute; bottom: 30px; right: 10px; background-color: #FFF; text-align: center; border: 1px solid #ccc; line-height: 30px; border-radius: 3px; padding: 0 5px; font-size: 12px; } */ #tip { background-color: #fff; padding-left: 10px; padding-right: 10px; position: absolute; font-size: 12px; right: 10px; top: 20px; border-radius: 3px; border: 1px solid #ccc; line-height: 30px; } /* #tip input[type='button'] { margin-top: 10px; margin-bottom: 10px; background-color: #0D9BF2; height: 30px; text-align: center; line-height: 30px; color: #fff; font-size: 12px; border-radius: 3px; outline: none; border: 0; } */ .amap-info-content { font-size: 12px; } /*#myPageTop {*/ /*position: absolute;*/ /*top: 5px;*/ /*right: 10px;*/ /*background: #fff none repeat scroll 0 0;*/ /*border: 1px solid #ccc;*/ /*margin: 10px auto;*/ /*padding:6px;*/ /*font-family: "Microsoft Yahei", "微软雅黑", "Pinghei";*/ /*font-size: 14px;*/ /*}*/ /*#myPageTop label {*/ /*margin: 0 20px 0 0;*/ /*color: #666666;*/ /*font-weight: normal;*/ /*}*/ /*#myPageTop input {*/ /*width: 170px;*/ /*}*/ /*#myPageTop .column2{*/ /*padding-left: 25px;*/ /*}*/
相关推荐
【ERP管理会计实训:战略地图之战略管理】 战略地图是一种重要的管理工具,它结合了平衡计分卡的四个层面——财务、客户、内部业务流程和学习与成长,以图形化的方式展示企业的战略因果关系。在ERP(Enterprise ...
开发者需要指定起点、终点和可能的途经点,API会计算出最佳或最短的路线并返回。这个过程可能涉及到地理编码(将地址转换为经纬度坐标)、驾车、步行或骑行等多种模式的选择。在得到路线信息后,通过API提供的方法将...
### 管理会计应用指引第 100 号——战略管理 #### 知识点解析 **一、战略管理的基本概念与原则** - **定义**:战略管理被定义为企业对其全局、长远发展的方向、目标、任务和资源配置作出决策与管理的过程。它涉及...
用户可以指定起点和终点,API会计算出最佳路径,同时提供语音导航、实时路况等增值服务。 8. **事件监听与位置更新**:开发者可以通过监听定位事件来获取位置变化,这在移动应用中常用于记录用户轨迹或实时更新地图...
开发者可以指定起点和终点,SDK会计算出最佳路线,并显示在地图上。同时,SDK还可以提供路线详情,如距离、预计时间等。 **4. 地理编码与反向地理编码** 通过MapPoint SDK,开发者可以实现将街道地址转换为经纬度...
这份名为“世界地图空白图集锦PPT学习教案”的文件是一个专门用于教学和学习的世界地理教育资源,适合在会计学等专业课程中作为辅助材料。它包含多张不同类型的地图,如世界地图、气候类型图、各大洲的政区图等,...
3. **路径规划**:地图定位小程序还常常包含路线规划功能,用户可以输入起始点和目的地,API会计算出最优的行驶路线,包括驾车、步行、骑行等多种模式,并显示预计的路程和时间。 4. **周边服务查询**:利用地图API...
通过处理公司的日常财务事务,实习生可以了解到如何将会计知识应用于实际商业环境中,如了解和使用各种地图产品的成本和收入数据,从而更好地理解企业的经济活动和运营模式。 在实习期间,实习生还会发现出纳工作与...
规划路线时,需要输入起始点和终点的坐标,API会计算出最佳路径,并返回路线的详细步骤、距离、预计行驶时间等信息。此外,百度地图还支持实时交通情况查询,可以帮助用户避开拥堵路段,提供更加准确的出行建议。 ...
很抱歉,根据您提供的信息,"素材图形地图学习教案.pptx"似乎是一个关于会计学的 PowerPoint 演示文稿,但具体内容并未在描述或标签中详细给出。通常,这样的文档可能会涵盖会计学的基础概念、图形表示方法、财务...
- 联系我们:包含联系方式、地图定位等,方便客户联系。 3. **响应式设计** 由于这个模板同时支持PC和WAP,意味着它是响应式的,能根据用户设备的屏幕尺寸自动调整布局,确保在不同设备上都有良好的用户体验。这...
1. **中国地图**:PPT的开始部分提到了“会计学1中国地图”,这可能是指在会计学的某个课程或讨论中,中国地图作为一个背景或者相关知识点出现。中国地图展示了中国的地理分布,可能包括省份、主要城市以及重要的...
该报告通过对不同性质公司会计主管薪酬的深入分析,为读者描绘出一个细致而全面的薪酬地图。报告的数据涵盖了外资企业、合资企业、本土私营企业和国有企业,四个主要的公司类型,这一划分方式使得我们能够直观地看到...
这份"模板中国地图与世界地图可编辑学习教案.ppt"是一个教育资料,主要包含中国地图、世界地图以及各大洲的地理分布。以下是其中涉及的知识点: 1. **中国地图**: - 中国地图展示了不同地区的监测站,包括哈尔滨...
总体而言,这份报告为拉萨地区的会计经理提供了一张详细的薪酬地图,帮助他们评估职业发展路径和薪资谈判的依据。同时,对于企业来说,这样的报告有助于他们在人才市场上制定更合理的薪酬策略,吸引并留住优秀的会计...
在会计学的教学与研究中,将抽象的经济数据与具体的空间地图相结合,能够有效提高学生的学习兴趣和对知识的理解。本文将探讨一种创新的学习工具——“中国各省市地图的资源可以改颜色PPT学习教案”,并分析其在教学...
8. **管理会计工具**:管理会计工具包括战略地图、滚动预算管理、作业成本管理等,它们是企业管理决策的重要支持工具。 9. **递延所得税的处理**:母子公司税率不一致时,递延所得税资产或负债的调整应基于被抵销...
开发者可以设定起点和终点,MapX会计算出最优路线。在MapSample中,这可能表现为一个寻路功能,用户输入起始和目的地后,地图上会高亮显示推荐的行驶路线。 总结来说,MapSample提供的示例将涵盖MapX控件的基本使用...
2. **战略地图管理**:这是一种可视化工具,帮助企业清晰地展示战略目标及其实施路径。 3. **作业成本法管理**:这种方法强调根据作业活动来分配成本,从而更准确地反映产品或服务的实际成本。 4. **超越预算管理**...
用户输入起始点和终点后,SDK会计算出最佳路线并显示在地图上。 5. **地理编码与反地理编码**:地理编码是将地址转换为经纬度坐标的过程,反地理编码则是将坐标转换回地址。这些功能在需要根据地址进行位置查找或者...