Javascript地理位置到10米以内

时间:2018-10-17 14:01:31

标签: javascript html geolocation

check_load v2.1.1 (monitoring-plugins 2.1.1)
Copyright (c) 1999 Felipe Gustavo de Almeida <galmeida@linux.ime.usp.br>
Copyright (c) 1999-2007 Monitoring Plugins Development Team
    <devel@monitoring-plugins.org>

This plugin tests the current system load average.

Usage:
check_load [-r] -w WLOAD1,WLOAD5,WLOAD15 -c CLOAD1,CLOAD5,CLOAD15

Options:
 -h, --help
    Print detailed help screen
 -V, --version
    Print version information
 --extra-opts=[section][@file]
    Read options from an ini file. See
    https://www.monitoring-plugins.org/doc/extra-opts.html
    for usage and examples.
 -w, --warning=WLOAD1,WLOAD5,WLOAD15
    Exit with WARNING status if load average exceeds WLOADn
 -c, --critical=CLOAD1,CLOAD5,CLOAD15
    Exit with CRITICAL status if load average exceed CLOADn
    the load average format is the same used by "uptime" and "w"
 -r, --percpu
    Divide the load averages by the number of CPUs (when possible)

Send email to help@monitoring-plugins.org if you have questions regarding
use of this software. To submit patches or suggest improvements, send email
to devel@monitoring-plugins.org

我在网上找到了此代码,并且效果很好,我只是想能够向对象添加多个位置,并且距离位置警报10米以内。不太确定如何开始使用任何帮助都很好,

1 个答案:

答案 0 :(得分:0)

这不是您可以采取的解决问题的答案,但是我会引导您正确的方向,并且我相信您可以解决此问题。

您的问题:

因此,首先,正如您已经提到的,此代码是一个很好的起点。 您描述了两个目标:

  1. 有多个位置
  2. 警告它们之间的距离是否在10米以下     其他

彼此解决

  1. 问题:您可能应该使用array来存储多个位置。 可能看起来像这样: var locations = [ {lat: 12.314, long: 0.125}, {lat: 12.314, long: 0.125} ] 要了解有关数组和基本JavaScript的更多信息,建议您参考here

  2. 问题: 您已经拥有解决此问题的复杂部分。您可以使用 function haversineDistance 计算两个位置之间的距离。因此,您要做的只是将您获得的每个新位置与当前所有现有位置进行比较,并使用alert()之类的内容来发出警报。 如果您愿意,我建议使用swal,但这与我的口味无关,与该项目无关。

但是没有什么比玩耍了解该语言和学习要好。