<tfoot id='KuiO4'></tfoot>
    <i id='KuiO4'><tr id='KuiO4'><dt id='KuiO4'><q id='KuiO4'><span id='KuiO4'><b id='KuiO4'><form id='KuiO4'><ins id='KuiO4'></ins><ul id='KuiO4'></ul><sub id='KuiO4'></sub></form><legend id='KuiO4'></legend><bdo id='KuiO4'><pre id='KuiO4'><center id='KuiO4'></center></pre></bdo></b><th id='KuiO4'></th></span></q></dt></tr></i><div id='KuiO4'><tfoot id='KuiO4'></tfoot><dl id='KuiO4'><fieldset id='KuiO4'></fieldset></dl></div>

      <legend id='KuiO4'><style id='KuiO4'><dir id='KuiO4'><q id='KuiO4'></q></dir></style></legend>
        <bdo id='KuiO4'></bdo><ul id='KuiO4'></ul>

      1. <small id='KuiO4'></small><noframes id='KuiO4'>

        舍入经纬度以在 Google 地图中显示大致位置

        时间:2023-09-07

            • <bdo id='5kCm5'></bdo><ul id='5kCm5'></ul>
              <legend id='5kCm5'><style id='5kCm5'><dir id='5kCm5'><q id='5kCm5'></q></dir></style></legend>
              <tfoot id='5kCm5'></tfoot>
              <i id='5kCm5'><tr id='5kCm5'><dt id='5kCm5'><q id='5kCm5'><span id='5kCm5'><b id='5kCm5'><form id='5kCm5'><ins id='5kCm5'></ins><ul id='5kCm5'></ul><sub id='5kCm5'></sub></form><legend id='5kCm5'></legend><bdo id='5kCm5'><pre id='5kCm5'><center id='5kCm5'></center></pre></bdo></b><th id='5kCm5'></th></span></q></dt></tr></i><div id='5kCm5'><tfoot id='5kCm5'></tfoot><dl id='5kCm5'><fieldset id='5kCm5'></fieldset></dl></div>

              <small id='5kCm5'></small><noframes id='5kCm5'>

                  <tbody id='5kCm5'></tbody>
                  本文介绍了舍入经纬度以在 Google 地图中显示大致位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在我的 Rails 应用程序视图中显示 Google 地图,并将使用标记/覆盖.

                  I'm displaying a Google map in my Rails app's view and will be using a marker/overlay.

                  坐标数据将来自手机 (GPS) 并存储在我的 Rails 应用程序的数据库中.

                  The coordinate data will be coming from a phone (GPS) and stored in my Rails app's db.

                  问题是,我不希望在我的网页源中显示精确的纬度/经度……也就是说,我想标记一个大概的位置,而不泄露真正的纬度/经度.

                  The problem is, I don't want the precise lat/long visible in the source of my web page ... i.e. I want to mark an approximate location without giving away the true lat/long.

                  如何舍入/截断纬度/经度值,使它们仍然准确(例如,在一英里内),但又不太准确?

                  How can I round/truncate the lat/long values so they are still accurate (say, within a mile)–but not too accurate?

                  (例如:你将如何舍入 35.2827524, -120.6596156 ?)

                  (Example: how would you round 35.2827524, -120.6596156 ?)

                  推荐答案

                  最简单的做法是将两个坐标四舍五入到一定的小数位,或者在坐标上添加随机抖动:

                  The easiest thing to do would be either to round both coordinates to a certain number of decimal places, or add a random dither to the coordinates:

                  lat = Math.floor(lat*1000+0.5)/1000; (round within 0.001)
                  

                  dither=0.001;
                  lat = lat + (Math.random()-0.5)*dither;
                  

                  如果你真的想在一定的英里数内,你需要做更复杂的数学,可能使用极坐标.

                  If you really want to be within a certain number of miles, you'd need to do more-complex math, probably using polar coordinates.

                  这篇关于舍入经纬度以在 Google 地图中显示大致位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:每次用户重新加载页面时,让 html5 地理定位请求 下一篇:未经许可的地理定位

                  相关文章

                  最新文章

                  <legend id='WmuSI'><style id='WmuSI'><dir id='WmuSI'><q id='WmuSI'></q></dir></style></legend>
                    1. <i id='WmuSI'><tr id='WmuSI'><dt id='WmuSI'><q id='WmuSI'><span id='WmuSI'><b id='WmuSI'><form id='WmuSI'><ins id='WmuSI'></ins><ul id='WmuSI'></ul><sub id='WmuSI'></sub></form><legend id='WmuSI'></legend><bdo id='WmuSI'><pre id='WmuSI'><center id='WmuSI'></center></pre></bdo></b><th id='WmuSI'></th></span></q></dt></tr></i><div id='WmuSI'><tfoot id='WmuSI'></tfoot><dl id='WmuSI'><fieldset id='WmuSI'></fieldset></dl></div>
                      • <bdo id='WmuSI'></bdo><ul id='WmuSI'></ul>
                      <tfoot id='WmuSI'></tfoot>
                    2. <small id='WmuSI'></small><noframes id='WmuSI'>