繁体   English   中英

Html地理位置无法在我的移动Web应用程序上运行| Spring MVC

[英]Html geolocation not working on my mobile web application | Spring MVC

我正在使用Spring MVC开发移动Web应用程序。 对于地理位置,我从这里获取代码

我在该网站上通过我的手机运行了演示,它要求获得位置许可,同样的事情在jsfiddle演示中,它正在工作。 如果我没有启用Gps,则会收到“无法检索您的位置”。

但是在我的应用程序中,我立即得到上述消息,而没有请求许可(同样,从chrome中删除了所有被阻止的应用程序)。

在PC上,地理定位正在通过我的应用程序工作,但在我的手机上,不是..问题是什么?意思是..为什么地理位置不能通过我的应用程序在我的手机上工作,但它适用于其他网站。 在我的手机上,直接进入error()函数。 也许我必须在配置文件中进行一些更改,否则我不知道..

LE:在另外两台设备上测试,输出相同:无法检索您的位置...(已启用GPS)

LE2: 我检查了错误代码。 我被许可拒绝 这是小提琴

<p><button onclick="geoFindMe()">Show my location</button></p>
<div id="out"></div>

//Javascript
function geoFindMe() {
  var output = document.getElementById("out");

  if (!navigator.geolocation){
    output.innerHTML = "<p>Geolocation is not supported by your browser</p>";
    return;
  }

  function success(position) {
    var latitude  = position.coords.latitude;
    var longitude = position.coords.longitude;

    output.innerHTML = '<p>Latitude is ' + latitude + '° <br>Longitude is ' + longitude + '°</p>';

    var img = new Image();
    img.src = "https://maps.googleapis.com/maps/api/staticmap?center=" + latitude + "," + longitude + "&zoom=13&size=300x300&sensor=false";

    output.appendChild(img);
  };

  function error() {
    output.innerHTML = "Unable to retrieve your location";
  };

  output.innerHTML = "<p>Locating…</p>";

  navigator.geolocation.getCurrentPosition(success, error);
}

您可以查看此代码, https://github.com/makubex88/MobileHTML5CodeCamp/blob/master/mobilehtml5.html

    function showPosition(position) {
            var latlon = position.coords.latitude + "," + position.coords.longitude;
            var img_url = "http://maps.googleapis.com/maps/api/staticmap?center="+latlon+"&zoom=14&size=400x300&sensor=false";
            document.getElementById("mapholder").innerHTML = "<img src='" + img_url + "'>";
        }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM