How to get points inside circle? - Google Maps v3
How to show points within circle on Google Map API v3 in a Query
In my previous post I explained Circle Draw with a Radius Google Maps v3. Here I will explain how to get points inside circle. Find MySQL query mentioned below.
- Find if points are within a circle with given center and radius
SELECT COUNT(*) FROM (SELECT (6371 * ACOS( COS( RADIANS('22.607672') ) * COS( RADIANS( Latitude ) ) * COS( RADIANS( Longitude ) - RADIANS('88.36853') ) + SIN( RADIANS('22.607672') ) * SIN( RADIANS( Latitude ) ) ) ) AS distance FROM bts HAVING distance < '7') a
- Query points within a given radius in MySQL
SELECT Latitude,Longitude FROM (SELECT Latitude,Longitude,(6371 * ACOS( COS( RADIANS('22.607672') ) * COS( RADIANS( Latitude ) ) * COS( RADIANS( Longitude ) - RADIANS('88.36853') ) + SIN( RADIANS('22.607672') )* SIN( RADIANS( Latitude ) ) ) ) AS distance FROM bts HAVING distance < '7') a
How to get points inside circle? - Google Maps v3
Reviewed by Ravi Kumar
on
12:11 PM
Rating:

Thanks a lot for this, could you also give the structure of the MySQL table here as I presume the type of fields will be important here for running this query?
ReplyDeleteThanks,
Alind
your welcome and thank you for your time!
ReplyDeleteya sure! there are following columns in MySQL table;-
Sno,BTS_ID,BTS_NAME,BTS_ADD,Latitude,Longitude,BTS_NODE_B_id,isActive