I am trying to implement a radius search feature on a website like this:
I have a clonable template 'Zone' with the following editable regions:
1. Zone name
2. Location/City
3. Location I'd
4. Longitude
5. Latitude
These fields will be populated using a databound form and Google maps location autocomplete API. Use types in a location and the Google API gives suggestions and then goes on to provide the location city, id, longitude and latitude into hidden fields which are in turn persisted into a cloned page.
Now on a separate page I want users to be able to see other Zones in a certain radius of a given Zone's(page) coordinates using Google maps API and SQL query like this:
I believe this is doable in Couch. My problem is how to run queries in Couch using query and php since I'm not a Mysql and php person.
Any help here
. Thank you
I have a clonable template 'Zone' with the following editable regions:
1. Zone name
2. Location/City
3. Location I'd
4. Longitude
5. Latitude
These fields will be populated using a databound form and Google maps location autocomplete API. Use types in a location and the Google API gives suggestions and then goes on to provide the location city, id, longitude and latitude into hidden fields which are in turn persisted into a cloned page.
Now on a separate page I want users to be able to see other Zones in a certain radius of a given Zone's(page) coordinates using Google maps API and SQL query like this:
- Code: Select all
SELECT
`id`,
`name`,
ACOS( SIN( RADIANS( `latitude` ) ) * SIN( RADIANS( $fLat ) ) + COS( RADIANS( `latitude` ) )
* COS( RADIANS( $fLat )) * COS( RADIANS( `longitude` ) - RADIANS( $fLon )) ) * 6380 AS `distance`
FROM `stations`
WHERE
ACOS( SIN( RADIANS( `latitude` ) ) * SIN( RADIANS( $fLat ) ) + COS( RADIANS( `latitude` ) )
* COS( RADIANS( $fLat )) * COS( RADIANS( `longitude` ) - RADIANS( $fLon )) ) * 6380 < 10
ORDER BY `distance`
<!--
where $fLat is the current pages(Zone's) latitude and $fLon the current page(Zone's) longitude. The ten in the where clause is the range you want to search within. Remember: This search is based on kilometers.
-->
I believe this is doable in Couch. My problem is how to run queries in Couch using query and php since I'm not a Mysql and php person.
Any help here
