首页 > 解决方案 > HTTP 中的地理位置

问题描述

我正在尝试获取用户的地理位置以在 http 网站的文本框中发布。我一直在测试中使用下面的代码,效果很好,但一旦部署就不起作用。

  if (navigator.geolocation) {
            navigator.geolocation.getCurrentPosition(success);
        } else {
            alert("Geo Location is not supported on your current browser!");
        }
        function success(position) {
            var latitude = position.coords.latitude;
            var longitude = position.coords.longitude;

            $('#click4').click(function () {
                document.getElementById('lat2').value = latitude + "." + longitude;
            });

我需要帮助弄清楚如何在 http 中进行这项工作。

标签: javahttpgeolocationgoogle-geolocation

解决方案


推荐阅读