用户位置自定义绘图工具中的mysql google maps查询存储?

标签 mysql google-maps maps

我正在使用这个工具 Drawing Tool places为了在 map 内绘制位置,我试图获取覆盖用户位置的位置。

例如:

用户不在粉红色或橙色形状内。 (地点) enter image description here

第二个形状内的用户(橙色位置) enter image description here

每个形状都有 long/lat 数组,我已经将它们添加到 places 表中,例如橙色形状数组是:

cursel: polygon [object Object]; pos: undefined ; path: [ 53.750107,-1.459851 , 53.750842,-1.461568 , 53.749954,-1.461825 , 53.749751,-1.464272 , 53.749117,-1.466203 , 53.748812,-1.469336 , 53.742493,-1.466074 , 53.738686,-1.46337 , 53.739143,-1.4538 , 53.740539,-1.45247 , 53.746985,-1.452899 , 53.749345,-1.455903 , 53.749218,-1.458092 , 

用户位置是:53.746858,-1.46513

** 放置表记录:**

placeId | long  | lat 
1 | 53.750919 | -1.471567
1 | 53.749675 | -1.473541
1 | 53.749066 | -1.472383
........
2 | 53.750107 | -1.459851
2 | 53.750842 | -1.461568
2 | 53.749954 | -1.461825
2 | 53.749751 | -1.464272
.......

我正在做这个查询:

select * from places where lat > '$lat' AND long < '$long'

这是表格结构:

//Place Name and ID
CREATE TABLE IF NOT EXISTS `place` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name ` varchar(70) NOT NULL
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

//Place Long/Lat borders <<-- here where i store the Array of long/lat of the place after it being draw  
CREATE TABLE IF NOT EXISTS `places` (
  `id` int(10) unsigned NOT NULL,
  `lat ` varchar(70) NOT NULL,
  `long ` varchar(70) NOT NULL
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ;

My problem with mysql query how to get the correct place within its range if its cover user location

非常感谢任何想法

最佳答案

select * from places where lat > '$lat' AND long < '$long'

只检查是否位于 [$lat, $long] 的西北部。因此,它或它的任何变体可能对这个问题毫无用处。

the_polygon 上创建一个 SPATIAL 索引。

使用 WHERE ST_Within(user_point, the_polygon) 查看用户是否在多边形中。

如果您需要更多帮助,请提供SHOW CREATE TABLE,以便我们在上下文中进行讨论。

关于用户位置自定义绘图工具中的mysql google maps查询存储?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48365512/

相关文章:

MySQL 更新与独特的连接

Mysql查询将总天数转换为年月日

google-maps - 如何使 Google map 居中而不位于屏幕中心?

MySQL:连接两个表并根据连接表中的两列填充字段

mysql - 如何改进 INSERT INTO ... SELECT 锁定行为

ios - 如何仅使用位置经度和纬度从 google place api 获取地点详细信息

android - 使用对象类中的纬度和经度在 Google map 上绘制 Pins/MapOverlays

javascript - 谷歌地图 API v3 : Driving directions over a map which first loads 2 positions

javascript - 为什么我的谷歌地图是空白的?

swift - 缩放 MapView 以显示 180 度经线的注释