通过谷歌地图(使用PHP)获取距离当前位置10公里以内的所有位置的纬度和经度

时间:2022-11-23 08:59:20

i am new to Google map things. i have a table in which there are list of all the location( the location of super stores) with their Latitude and Longitude .

我是谷歌地图新手。我有一个表,其中有所有位置(超级商店的位置)及其纬度和经度的列表。

Now i want to know all possible location(may b Latitude and Longitude ) of these super stores that are within 10km radius of my current location.

现在我想知道这些超级商店的所有可能的位置(可能是纬度和经度),它们位于我当前位置的半径10公里以内。

I have no idea how i can do this using Google map (in php code). What Google map API should i used ? Any suggestion ,project code, information will be helpful for me

我不知道如何使用谷歌映射(在php代码中)实现这一点。我应该使用什么谷歌地图API ?任何建议、项目代码、信息都会对我有帮助

Thanks in Advance

谢谢提前

3 个解决方案

#1


13  

See Radius search with Google Maps and MySQL

使用谷歌地图和MySQL查看Radius搜索。

#2


7  

You can Use Following Query of Mysql to get all stores within specified miles

您可以使用以下Mysql查询获得指定英里内的所有存储

select * from stores where lat!='' and lng!='' and ( 3959 * acos( cos( radians(" . $centerpoints['lat'] . ") ) * cos( radians( lat ) ) * cos( radians( lng ) - radians(" . $centerpoints['lng'] . ") ) + sin( radians(" . $centerpoints['lat'] . ") ) * sin( radians( lat ) ) ) ) < " . $distanceInMile

#3


6  

https://developers.google.com/maps/articles/phpsqlsearch_v3 Have a look at above. Should give you a good idea.

https://developers.google.com/maps/articles/phpsqlsearch_v3可以在上面看到。应该给你一个好主意。

To find locations in your markers table that are within a certain radius distance of a given latitude/longitude, you can use a SELECT statement based on the Haversine formula. The Haversine formula is used generally for computing great-circle distances between two pairs of coordinates on a sphere. An in-depth mathemetical explanation is given by Wikipedia and a good discussion of the formula as it relates to programming is on Movable Type's site.

要在标记表中找到在给定纬度/经度的一定半径范围内的位置,可以使用基于Haversine公式的SELECT语句。Haversine公式通常用于计算球面上两对坐标之间的大圆距离。*给出了一个深入的数学解释,并且在Movable Type的网站上对这个公式进行了很好的讨论。

Here's the SQL statement that will find the closest 20 locations that are within a radius of 25 miles to the 37, -122 coordinate. It calculates the distance based on the latitude/longitude of that row and the target latitude/longitude, and then asks for only rows where the distance value is less than 25, orders the whole query by distance, and limits it to 20 results. To search by kilometers instead of miles, replace 3959 with 6371.

这是一条SQL语句,它将找到距离半径25英里到37 -122坐标范围内的最接近的20个位置。它根据行的纬度/经度和目标纬度/经度计算距离,然后只要求距离值小于25的行,按距离顺序排列整个查询,并将其限制为20个结果。用千米代替英里搜索,用6371代替3959。

#1


13  

See Radius search with Google Maps and MySQL

使用谷歌地图和MySQL查看Radius搜索。

#2


7  

You can Use Following Query of Mysql to get all stores within specified miles

您可以使用以下Mysql查询获得指定英里内的所有存储

select * from stores where lat!='' and lng!='' and ( 3959 * acos( cos( radians(" . $centerpoints['lat'] . ") ) * cos( radians( lat ) ) * cos( radians( lng ) - radians(" . $centerpoints['lng'] . ") ) + sin( radians(" . $centerpoints['lat'] . ") ) * sin( radians( lat ) ) ) ) < " . $distanceInMile

#3


6  

https://developers.google.com/maps/articles/phpsqlsearch_v3 Have a look at above. Should give you a good idea.

https://developers.google.com/maps/articles/phpsqlsearch_v3可以在上面看到。应该给你一个好主意。

To find locations in your markers table that are within a certain radius distance of a given latitude/longitude, you can use a SELECT statement based on the Haversine formula. The Haversine formula is used generally for computing great-circle distances between two pairs of coordinates on a sphere. An in-depth mathemetical explanation is given by Wikipedia and a good discussion of the formula as it relates to programming is on Movable Type's site.

要在标记表中找到在给定纬度/经度的一定半径范围内的位置,可以使用基于Haversine公式的SELECT语句。Haversine公式通常用于计算球面上两对坐标之间的大圆距离。*给出了一个深入的数学解释,并且在Movable Type的网站上对这个公式进行了很好的讨论。

Here's the SQL statement that will find the closest 20 locations that are within a radius of 25 miles to the 37, -122 coordinate. It calculates the distance based on the latitude/longitude of that row and the target latitude/longitude, and then asks for only rows where the distance value is less than 25, orders the whole query by distance, and limits it to 20 results. To search by kilometers instead of miles, replace 3959 with 6371.

这是一条SQL语句,它将找到距离半径25英里到37 -122坐标范围内的最接近的20个位置。它根据行的纬度/经度和目标纬度/经度计算距离,然后只要求距离值小于25的行,按距离顺序排列整个查询,并将其限制为20个结果。用千米代替英里搜索,用6371代替3959。