How PHP can find a point, within a certain distance, the latitude and longitude range

Source: Internet
Author: User
/**

  • @param double $x Longitude

  • @param double $y latitude

  • @param double $d distance unit/meter

  • @return Array
    */

function GetRange ($x, $y, $d) {

}

As above function,
$x indicates the longitude of the point
$y represents the latitude of the point
$d distance from the point of departure
Return latitude and longitude range

Reply content:

/**

  • @param double $x Longitude

  • @param double $y latitude

  • @param double $d distance unit/meter

  • @return Array
    */

function GetRange ($x, $y, $d) {

}

As above function,
$x indicates the longitude of the point
$y represents the latitude of the point
$d distance from the point of departure
Return latitude and longitude range

Go to Google "calculate the distance between two points by latitude"

If the accuracy requirements are not high, you can calculate it by yourself. The radius of the Earth, you know? Longitude is dividing the Earth's surface into 360 equal latitudes, the latitude is divided into 180 equal, so that the distance and the center point given to calculate the span of latitude and longitude.

If the accuracy requirements are high, it is best to see if there is a third-party professional interface can be used (such as Google Maps, high-level map, Baidu map These)

Isn't that a math problem?

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.