zoukankan      html  css  js  c++  java
  • 手机获得经纬度

    <script src="jquery-2.1.3.min.js"></script>
    
     
    
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=您的密钥"></script>
    
    <div id="allmap" style="height: 500px;"></div>
    <div id="r-result">
    经度: <input id="longitude" type="text" style="100px; margin-right:10px;" />
    纬度: <input id="latitude" type="text" style="100px; margin-right:10px;" />
    <input type="button" value="查询" onclick="theLocation()" />
    </div>
    

      

    <script type="text/javascript">
    // 百度地图API功能
    var map = new BMap.Map("allmap");
    map.centerAndZoom(new BMap.Point(116.331398,39.897445),11);
    map.enableScrollWheelZoom(true);
    
    // 用经纬度设置地图中心点
    function theLocation(){
    if(document.getElementById("longitude").value != "" && document.getElementById("latitude").value != ""){
    map.clearOverlays(); 
    var new_point = new BMap.Point(document.getElementById("longitude").value,document.getElementById("latitude").value);
    var marker = new BMap.Marker(new_point); // 创建标注
    map.addOverlay(marker); // 将标注添加到地图中
    map.panTo(new_point); 
    }
    }
    
    
    var a=document.getElementById("latitude");//纬度
    var b=document.getElementById("longitude");//经度
    
    $(document).ready(function(){
    if (navigator.geolocation){
    navigator.geolocation.getCurrentPosition(showPosition);
    }else{
    x.innerHTML="该浏览器不支持获取地址位置.";//不起作 用
    }
    });
    
    function showPosition(position){
    a.value = position.coords.latitude;
    b.value = position.coords.longitude;
    
    }
    </script>
    

      

  • 相关阅读:
    1065. [Nescafe19] 绿豆蛙的归宿(概率)
    SDOI 2016 Round1 Day2
    SDOI 2016 Round1 Day1
    Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined)
    串 2016Vijos省选集训 day3[AC自动机]
    java连接elastic search 9300
    maven安装,maven命令行使用
    eclipse/IDEA使用maven
    hadoop笔记 基础 归档
    tpot蜜罐平台搭建
  • 原文地址:https://www.cnblogs.com/JamyWong/p/7623161.html
Copyright © 2011-2022 走看看