在谷歌地图上搜索一个矩形

时间:2013-11-20 10:26:41

标签: google-maps google-maps-api-3 latitude-longitude

我们在Sql server数据库中有Locations个数据。为每个bounding rectangle定义了四个点(Location)。四点是Bottom Latitude, Top Latitude, Left Longitude, Right Longitude。如果googlemaps属于边界矩形的任何区域,则会为该位置绘制标记。

我们在数据库中还有一些其他位置,我们只存储了Lat Lng,我们正在使用以下查询进行搜索,它确实有效!

SELECT   *
FROM     SomeOtherLocationsTable
WHERE    LocationLatitude >= @bottomlat  AND
         LocationLatitude <= @toplat AND
         LocationLongitue >= @leftlang AND
         LocationLongitue <= @rightlng

我们如何搜索为其定义了四个点的位置?

2 个答案:

答案 0 :(得分:1)

使用STIntersects

而不是数字,你应该存储geometries(那么你可以对POINTS和POLYGONS使用相同的查询)

答案 1 :(得分:0)

R & D之后,我们能够找到以下解决方案并为我们工作(我们只需要美国地区的功能):

SELECT   *
FROM     LocationsTable
WHERE    
    NorthEastLongitudeRectangle < @SouthWestLongitudeRectangle OR
    SouthWestLongitudeRectangle > @NorthEastLongitudeRectangle OR
    NorthEastLatitudeRectangle  < @SouthWestLatitudeRectangle  OR
    SouthWestLatitudeRectangle1 > @NorthEastLatitudeRectangle

我们仍在测试它,但希望它会起作用!

相关问题