百度地图接口
引入百度api<script src="http://api.map.baidu.com/api?v=1.4" type="text/javascript"></script>
var getLocation = function (successFunc, errorFunc) { //successFunc获取定位成功回调函数,errorFunc获取定位失败回调 //首先设置默认城市 var defCity = { id: '000001', name: '北京市', date: curDateTime()//获取当前时间 *** }; //默认城市 $.cookie('VPIAO_MOBILE_DEFAULTCITY', *** ON.stringify(defCity), { expires: 1, path: '/' }); if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function (position) { var lat = position.coords.latitude; var lon = position.coords.longitude; //var map = new BMap.Map("container"); // 创建Map实例 var point = new BMap.Point(lon, lat); // 创建点坐标 var gc = new BMap.Geocoder(); gc.getLocation(point, function (rs) { var addComp = rs.addressComponents; var curCity = { id: '', name: addComp.province, date: curDateTime() }; //当前定位城市 $.cookie('VPIAO_MOBILE_CURRENTCITY', *** ON.stringify(curCity), { expires: 7, path: '/' }); //alert(addComp.province + ", " + addComp.city + ", " + addComp.district + ", " + addComp.street); if (successFunc != undefined) successFunc(addComp); }); }, function (error) { switch (error.code) { case 1: alert("位置服务被拒绝。"); break; case 2: alert("暂时获取不到位置信息。"); break; case 3: alert("获取位置信息超时。"); break; default: alert("未知错误。"); break; } var curCity = { id: '000001', name: '北京市', date: curDateTime() }; //默认城市 $.cookie('VPIAO_MOBILE_DEFAULTCITY', *** ON.stringify(curCity), { expires: 1, path: '/' }); if (errorFunc != undefined) errorFunc(error); }, { timeout: 5000, enableHighAccuracy: true }); } else { alert("你的浏览器不支持获取地理位置信息。"); if (errorFunc != undefined) errorFunc("你的浏览器不支持获取地理位置信息。"); } }; var showPosition = function (position) { var lat = position.coords.latitude; var lon = position.coords.longitude; //var map = new BMap.Map("container"); // 创建Map实例 var point = new BMap.Point(lon, lat); // 创建点坐标 var gc = new BMap.Geocoder(); gc.getLocation(point, function (rs) { var addComp = rs.addressComponents; var curCity = { id: '', name: addComp.province, date: curDateTime() }; //当前定位城市 $.cookie('VPIAO_MOBILE_CURRENTCITY', *** ON.stringify(curCity), { expires: 7, path: '/' }); //alert(addComp.province + ", " + addComp.city + ", " + addComp.district + ", " + addComp.street); }); }; var showPositionError = function (error) { switch (error.code) { case 1: alert("位置服务被拒绝。"); break; case 2: alert("暂时获取不到位置信息。"); break; case 3: alert("获取位置信息超时。"); break; default: alert("未知错误。"); break; } var curCity = { id: '000001', name: '北京市', date: curDateTime() }; //默认城市 $.cookie('VPIAO_MOBILE_DEFAULTCITY', *** ON.stringify(curCity), { expires: 1, path: '/' }); };
纯js性 简单快速 功能少 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <titl...
<script type="text/javascript">(function(Switch) { var switch_pc = window.location.hash; ...
浏览器网页定时刷新代码教程分享,只需要一段js代码 首先F12打开控制器面板,复制刷新代码 timeout=prompt("Set timeout (Second):"); count=...
//屏蔽F12和右键 function click(e) { if (document.all) { if (event.button==2||event.button==3) { alert("你...
/*站外输出网站时加上特殊标识符*/ $("a").each(function(index, item) { var url = $(item).attr("href"); if (u...
资源网,博客文章页面增加访问停留时间代码 <!-- 统计访客停留时间 --> <div id="tingliu"> </span> <span clas...