地图获取坐标 腾讯地图批量转坐标
腾讯地图批量转坐标-demo
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" /> <title>地址解析</title> <style type="text/css"> * { margin: 0px; padding: 0px; } body, button, input, select, textarea { font: 12px/16px Verdana, Helvetica, Arial, sans-serif; } p { width: 1627px; padding-top: 3px; margin-top: 0px; overflow: hidden; line-height: 100%; } input#address { width: 300px; } </style> <script charset="utf-8" src="https://map.qq.com/api/js?v=2.exp&key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77"></script> <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"> </script> </head> <body onload="init()"> <script type="text/javascript"> $(function () { localStorage.wxdindex = 0; }) </script> <script> var geocoder, map, marker = null; var init = function () { var center = new qq.maps.LatLng(39.916527, 116.397128); map = new qq.maps.Map(document.getElementById(‘container‘), { center: center, zoom: 15, }); //地址和经纬度之间进行转换服务 geocoder = new qq.maps.Geocoder(); //设置服务请求成功的回调函数 geocoder.setComplete(function (result) { $("#wxd").append("<p>(‘" + orgid + "‘,‘" + result.detail.address + "‘," + result.detail.location.lat + "," + result.detail.location.lng + ")</p>"); $ }); //若服务请求失败,则运行以下函数 geocoder.setError(function () { $("#wxd2").append("<p>‘" + source[Number(localStorage.wxdindex)].id + "‘</p>"); }); } var orgid = ""; var source = [{ id: "00003B1C483DE0000C80", address: "广东省广州市珠海区广州大厦南1276A区A12-A13,D区D1-D6,F区F9-F14" }, { id: "00003BDB25DAF0000CA2", address: "山东省济宁高新区327国道南营村虎标工业园院内" } ]; function codeAddress() { var i = localStorage.wxdindex; orgid = source[i].id; geocoder.getLocation(source[i].address); localStorage.wxdindex = Number(localStorage.wxdindex) + 1; } //定时任务总次数 var maxCount = source.length; //随机单位时间范围 var minNum = 1, maxNum = 10; //执行时间单位(1毫秒,10/10毫秒;100/百秒;1000/秒,) var p_unit = 100; //随机数函数 function randomNum(minNum, maxNum) { switch (arguments.length) { case 1: return parseInt(Math.random() * minNum + 1, 10); break; case 2: return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10); break; default: return 0; break; } } //时间格式化 function timestampToTime(timestamp) { var date = new Date();//时间戳为10位需*1000,时间戳为13位的话不需乘1000 var Y = date.getFullYear() + ‘-‘; var M = (date.getMonth() + 1 < 10 ? ‘0‘ + (date.getMonth() + 1) : date.getMonth() + 1) + ‘-‘; var D = (date.getDate() < 10 ? ‘0‘ + date.getDate() : date.getDate()) + ‘ ‘; var h = (date.getHours() < 10 ? ‘0‘ + date.getHours() : date.getHours()) + ‘:‘; var m = (date.getMinutes() < 10 ? ‘0‘ + date.getMinutes() : date.getMinutes()) + ‘:‘; var s = (date.getSeconds() < 10 ? ‘0‘ + date.getSeconds() : date.getSeconds()); strDate = Y + M + D + h + m + s; return strDate; } //随机数实例函数 function num(unit) { if (!unit) unit = p_unit; var n = randomNum(1, 5); var nowDate = new Date().getTime(); console.log(timestampToTime(nowDate) + "间隔" + n * unit / 1000 + "秒执行"); return n * unit; } //执行任务. var ii = setInterval(befor, num()); var index = 1; function befor() { //方法可取消由 setInterval() 函数设定的定时执行操作 clearInterval(ii); //主函数 codeAddress(); console.log("淘小人提醒您:任务总次数>>>"+maxCount+", 当前执行次数>>>" + index) //递归 if (index <= 55) { ii = setInterval(befor, num()) } else { console.log("淘小人提醒您,任务完毕.总执行次数>>>" + index) } //递归使用,当前索引+1 index = index + 1; } </script> <div> <input id="address" type="textbox" value="中国,北京,海淀区,海淀大街38号"> <button onclick="codeAddress()">search</button> </div> <div style="width:603px;height:300px" id="container"></div> <p>输入地址,点击search进行地址解释,点击Marker会弹出反查结果。</p> <div id="wxd"></div> <div id="wxd2" style="color:red"></div> </body> </html>
百度摄取坐标-demo
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <style type="text/css"> body, html {width: 100%;height: 100%;margin:0;font-family:"微软雅黑";} #allmap{width:100%;height:500px;} p{margin-left:5px; font-size:14px;} </style> <script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=4e9dxOHo69bEAotI6TbIKnq1"></script> <title>根据关键字本地搜索</title> </head> <body> <div id="allmap" style="height:500px;width:600px;margin: 0 auto;"></div> <div style="padding-left:200px; margin: 0 auto;">测试数据:<br /> 易县光达汽车贸易有限公司<br /> 涿州市朗杰汽车贸易有限公司<br /> 保定欧美亚汽车销售服务有限公司<br /> 保定奔腾汽车贸易有限公司<br /> 保定五洲创业汽车销售服务有限公司<br /> 安国市竣祥汽车贸易有限公司<br /> 安新县杰骏汽车销售有限公司<br /> 博野县国鑫汽贸有限公司<br /> 顺平县佳华汽车销售服务有限公司<br /> <input type="input" name="user_email" id="keys" value="安新县杰骏汽车销售有限公司" placeholder="请输入你的内容" /> <button onclick="copyText()">搜索</button> <input type="button" onclick="remove_overlay();" value="删除地图点,手动选择" /> </div> </body> </html> <script type="text/javascript"> var map = new BMap.Map("allmap"); // 创建Map实例 map.centerAndZoom("保定市",14); // 初始化地图,用城市名设置地图中心点 map.enableScrollWheelZoom(true); //开启鼠标滚轮缩放 var pointArray = new Array(); function copyText(){ //2.搜索 var options = { onSearchComplete: function(results){ // 判断状态是否正确 if (local.getStatus() == BMAP_STATUS_SUCCESS){ for (var i = 0; i < results.getCurrentNumPois(); i ++){ var marker = new BMap.Marker(new BMap.Point(results.getPoi(i).point.lng, results.getPoi(i).point.lat)); // 创建点 map.addOverlay(marker); var label = new BMap.Label(results.getPoi(i).title,{offset:new BMap.Size(20,-10)}); marker.setLabel(label); pointArray[i] = new BMap.Point(results.getPoi(i).point.lng, results.getPoi(i).point.lat); marker.addEventListener("click",attribute); } map.setViewport(pointArray); } } }; var local = new BMap.LocalSearch(map, options); local.search(document.getElementById(‘keys‘).value); } //获取覆盖物位置 function attribute(e){ map.removeEventListener("click",showInfo); var p = e.target; alert("你确认选择该位置为经销商门店地址么?(坐标:" + p.getPosition().lng + "," + p.getPosition().lat+")"); } function showInfo(e){ var marker = new BMap.Marker(new BMap.Point(e.point.lng, e.point.lat)); // 创建点 map.addOverlay(marker); marker.addEventListener("click",attribute); } //清除覆盖物 function remove_overlay(){ map.clearOverlays(); map.addEventListener("click", showInfo); } </script>
相关推荐
coolhty 2020-06-13
etzt 2020-04-16
etzt 2020-01-06
worldkun 2019-12-20
shilongdred 2019-12-22
蔷薇部落 2014-01-20
nutian 2014-01-15
nutian 2014-01-13
songyaping0 2011-07-19
jishume 2011-07-19
邱石 2011-07-19
xcjing 2015-11-12
dutiyanwang 2012-04-18
Eric实验室 2019-04-26
XiaoyiXie 2019-04-25
缘起宇轩阁 2019-09-03
zhuyonge 2015-12-03