zoukankan      html  css  js  c++  java
  • 获取当前地址

    /*获取当前位置start*/
    function getLocation(elem)
    {
    if (navigator.geolocation)
    {
    //navigator.geolocation.getCurrentPosition(function(position){
    var geolocation = new BMap.Geolocation();
    geolocation.getCurrentPosition(function(position){
    //var W_ = position.coords.latitude;//维度
    //var J_ = position.coords.longitude;//经度
    var W_ =position.point.lat;
    var J_ =position.point.lng;
    Select(W_,J_,elem);
    });
    }
    else{
    alert("无法获取当前位置");
    }
    }
    var SAMPLE_POST_REVERSE = 'https://api.map.baidu.com/geocoder/v2/?ak=密钥&callback=renderReverse&s=1';
    var safe = '';
    var pois;
    function showReverseURL(latitude,longitude,elem)
    {
    safe = SAMPLE_POST_REVERSE;
    safe += "&location=" + latitude + "," + longitude;
    safe += "&output=json";
    safe += '&pois=' + pois;

    };

    function Select(latitude,longitude,elem)
    {
    var script = document.createElement('script');
    script.type = 'text/javascript';
    showReverseURL(latitude,longitude,elem);
    var newURL = safe.replace('密钥', '密钥值');
    script.src = newURL;
    document.body.appendChild(script);
    };

    function renderReverse(response)
    {
    var val = '';
    if (response.status)
    {
    alert("无正确的返回结果");
    return;
    }
    var location = response.result.location;
    if(response.result.formatted_address == "")
    {
    alert("无正确的返回结果");
    }
    else
    {
    val=response.result.formatted_address+response.result.sematic_description;
    }

    if (pois == 1)
    {
    val="";
    }
    window.elem.val(val);

    // $("#address").val(val);
    return;
    }
    /*获取当前位置end*/
  • 相关阅读:
    (九)排序——选择
    (八)排序——冒泡
    (七)排序算法
    (六)递归
    (五)栈
    (三)队列
    (二)稀疏数组
    Nessus号称是世界上最流行的漏洞扫描程序
    meterpreter ???
    IIS网站权限设置原则
  • 原文地址:https://www.cnblogs.com/wanan-01/p/7474519.html
Copyright © 2011-2022 走看看