h5获取经纬度有问题

function justify_location(){
       if(navigator.geolocation) {
           // 支持
           console.log("支持地理位置接口");
       } else {
           // 不支持
           console.log("不支持地理位置接口");
       }
   }

    function agree_obtain_location(){
       var option = {
           enableHighAccuracy : true,
           timeout : Infinity,
           maximumAge : 0
       };

       navigator.geolocation.getCurrentPosition(geoSuccess,geoError,option);

   }

   function geoSuccess(event) {
       console.log(event.coords.latitude + ', ' + event.coords.longitude);
       lat=event.coords.latitude;
       lng=event.coords.longitude;

       console.log(lat,lng)
   }

   function geoError(event) {
       console.log("Error code " + event.code + ". " + event.message);
   }

   justify_location();

   agree_obtain_location();


用这个方法,不稳定,有时候可以,有时候不行,打包成app也不可以了,请问有什么好的稳定的方法呢~~?

陌上人如玉_010
浏览 6592回答 2
2回答

慕粉2221296265

调百度地图接口

高jay

调百度地图接口
打开App,查看更多内容
随时随地看视频慕课网APP