PHP calculates the maximum and minimum longitude and latitude examples of 4 corners within 3 kilometers of the current coordinates, current longitude and latitude_PHP tutorial

WBOY
Release: 2016-07-12 08:58:13
Original
1011 people have browsed it

An example of PHP calculating the maximum and minimum longitude and latitude of 4 corners within 3 kilometers of the current coordinates. Current longitude and latitude

This article describes an example of PHP calculating the maximum and minimum of 4 corners within 3 kilometers of the current coordinates. latitude and longitude method. Share it with everyone for your reference, the details are as follows:

//$lng 、$lat 经纬度    
$half = 6371;
    $distance = 3; //3公里 
    $dlng = 2 * asin(sin($distance / (2 * $half)) / cos(deg2rad($lat)));
    $dlng = rad2deg($dlng);
    $dlat = $distance / $half;
    $dlat = rad2deg($dlat);
    $fourpoint = array(
      'left-top' => array('lat' => $lat + $dlat, 'lng' => $lng - $dlng),
      'right-top' => array('lat' => $lat + $dlat, 'lng' => $lng + $dlng),
      'left-bottom' => array('lat' => $lat - $dlat, 'lng' => $lng - $dlng),
      'right-bottom' => array('lat' => $lat - $dlat, 'lng' => $lng + $dlng)
);

Copy after login

Readers who are interested in more PHP-related content can check out the special topics of this site: "Summary of PHP Date and Time Usage", "Introduction Tutorial on PHP Object-Oriented Programming", "Summary of PHP String Usage", " PHP mysql database operation introductory tutorial" and "php common database operation skills summary"

I hope this article will be helpful to everyone in PHP programming.

Articles you may be interested in:

  • How to obtain all the information (address, postal code, country, longitude and latitude, etc.) of a specified (visitor) IP in PHP
  • PHP based on two Calculate the distance between points by latitude and longitude
  • PHP code for calculating the distance between latitude and longitude of 2 points
  • php method of using Jpgraph to draw complex X-Y coordinate diagrams
  • php using Jpgraph to draw simple X-Y Coordinate map method
  • PHP method to calculate the distance between two coordinates (longitude, latitude)
  • PHP method to calculate the distance between two GPS coordinates on Baidu map

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1104333.htmlTechArticlePHP calculates the maximum and minimum longitude and latitude of 4 corners within 3 kilometers of the current coordinates. The current longitude and latitude are examples in this article about PHP calculations The maximum and minimum longitude and latitude of the four corners within 3 kilometers of the current coordinates...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!