appCan uexLocation 定位功能

js的引用:

 <script src="../js/zy_control.js"></script>
 <script src="../js/zy_anim.js"></script>
 <script src="../js/zy_json.js"></script>
 <script src="../js/zy_tmpl.js"></script>

html 代码:

 <div id="header" class="uh t-wh ub c-blu">
                <div class="umw4 ub ub-ac ub-pc" ontouchstart="zy_touch()" onclick="mapOpen()">
                    打开
                </div>
                <h1 class="ut ub-f1 ulev-3 ut-s tx-c" tabindex="0">百度地图</h1>
                <div class="umw4 ub ub-ac ub-pc" ontouchstart="zy_touch()" onclick="mapClean()">
                    关闭
                </div>
                <div class="umw4 ub ub-ac ub-pc" ontouchstart="zy_touch()" onclick="getLocation()">
                    定位
                </div>
            </div>

js 代码:

<script>
zy_init();
window.uexOnload = function(type){
if (!type) {
//回调函数
uexWidgetOne.onError = function(opCode, errorCode, errorDesc){
alert(errorCode + ':' + errorDesc);
}
//获取当前经纬度回调
uexBaiduMap.cbGetCurrentLocation = function(opId, dataType, data){
alert(JSON.parse(data).longitude + ' ' + JSON.parse(data).latitude);
}
//根据地名获取地址经纬度信息回调
uexBaiduMap.cbGeocode = function(opId, dataType, data){
alert(data);
}
//根据经纬度获取地址详细信息回调
uexBaiduMap.cbReverseGeocode = function(opId, dataType, data){
alert(data);
}
//根据公交线路编号在指定城市范围内搜索公交线路详情回调
uexBaiduMap.cbBusLineSearch = function(opId, dataType, data){
alert(data);
}
//根据传入参数信息在地图上显示规划的线路回调
uexBaiduMap.cbShowRoutePlan = function(opId, dataType, data){
alert(data);
}
}
}

var lat;
var log;

function $$(id){
returndocument.getElementById(id);
}

//定位开始
function getLocation(){
uexLocation.onChange = function(inLat, inLog){
lat=intLat;
log=intLog;
uexLocation.cbGetAddress = getAddress;
uexLocation.getAddress(inLat, inLog);
uexLocation.closeLocation();
}
uexLocation.openLocation();
}

function getAddress(opId, dataType, data){
$("#location").html(inLat);
}

//打开地图
function mapOpen(){//定位员工当前位置
alert(log+":"+lat);
uexBaiduMap.open('6643147DF56BD40F6140AB3ABA5A3FFBE12C439F', '0', '160', '1100', '1200', log, lat);
}

//关闭地图
function mapClean(){
uexBaiduMap.clean();
}

</script>

posted @ 2014-08-04 14:37  忆森灵  阅读(3187)  评论(4编辑  收藏  举报