使用Google地图在定义区域列出事件 [英] List Events on defined area using Google Maps

查看:126
本文介绍了使用Google地图在定义区域列出事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有谷歌地图定义了很多事件等。



我如何列出所有事件,例如。因为你的问题有点含糊,我假设你有一个lat,long坐标列表。您可以使用类似下面的方法将它们从SQL中取出:

  SELECT 
z.id AS z__id,
z.zipcode AS z__zipcode,
z.city AS z__city,
z.state AS z_state,
z.county AS z__county,
z.zip_class AS z__zip_class,
(纬度/海平面/ 180)* SIN(z.latitude * PI()/ 180)+ COS(纬度/海平面) *(180度)* 180度(180度)* 180度* 180度)* COS(z.latitude * PI()/ 180)* COS(( - z.longitude)* PI()/ 180) ()()()()()()()()()()() ()/ 180)* COS(( - z.longitude)* PI()/ 180))* 180 / PI())* 60 * 1.1515 * 1.609344)AS z__1
FROM zipcode z
WHERE z.city!=?
ORDER BY z__0 asc
LIMIT 50

z_ 0将会(以千米为单位),而z-1将以千米为单位的距离。 b
$ b

(来源: http://www.doctrine-project.org/projects/orm/1.2/docs/手动/行为/ EN#核心行为:地理上的)



或者使用类似的东西(类似于php):

 函数距离($ lat1,$ lon1,$ lat2,$ lon2,$ unit){

$ theta = $ lon1 - $ lon2;
$ dist = sin(deg2rad($ lat1))* sin(deg2rad($ lat2))+ cos(deg2rad($ lat1))* cos(deg2rad($ lat2))* cos(deg2rad($ theta) );
$ dist = acos($ dist);
$ dist = rad2deg($ dist);
$ miles = $ dist * 60 * 1.1515;
$ unit = strtoupper($ unit);

if($ unit ==K){
return($ miles * 1.609344);
} else if($ unit ==N){
return($ miles * 0.8684);
} else {
return $ miles;
}
}

http://www.zipcodeworld.com/samples/distance.php.html


I have Google Map with defined a lot of events etc.

How I can list all events eg. in 50km around my location?

解决方案

Since your question is a bit vague, I assume you have a list of lat, long coordinates. You can get them out of SQL using something like this:

SELECT 
z.id AS z__id, 
z.zipcode AS z__zipcode, 
z.city AS z__city, 
z.state AS z__state, 
z.county AS z__county, 
z.zip_class AS z__zip_class, 
z.latitude AS z__latitude, 
z.longitude AS z__longitude, 
((ACOS(SIN(* PI() / 180) * SIN(z.latitude * PI() / 180) + COS(* PI() / 180) * COS(z.latitude * PI() / 180) * COS((- z.longitude) * PI() / 180)) * 180 / PI()) * 60 * 1.1515) AS z__0, 
((ACOS(SIN(* PI() / 180) * SIN(z.latitude * PI() / 180) + COS(* PI() / 180) * COS(z.latitude * PI() / 180) * COS((- z.longitude) * PI() / 180)) * 180 / PI()) * 60 * 1.1515 * 1.609344) AS z__1 
FROM zipcode z 
WHERE z.city != ? 
ORDER BY z__0 asc 
LIMIT 50

z_0 will be the dinstance in miles, whereas z_1 will be the distance in km.

(source: http://www.doctrine-project.org/projects/orm/1.2/docs/manual/behaviors/en#core-behaviors:geographical)

Or use something like this (similar in php):

function distance($lat1, $lon1, $lat2, $lon2, $unit) { 

  $theta = $lon1 - $lon2; 
  $dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) +  cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta)); 
  $dist = acos($dist); 
  $dist = rad2deg($dist); 
  $miles = $dist * 60 * 1.1515;
  $unit = strtoupper($unit);

  if ($unit == "K") {
    return ($miles * 1.609344); 
  } else if ($unit == "N") {
      return ($miles * 0.8684);
    } else {
        return $miles;
      }
}

http://www.zipcodeworld.com/samples/distance.php.html

这篇关于使用Google地图在定义区域列出事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆