you might use this php wise: (untested) SELECT id, ( 3959 * acos( cos( radians(37) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians(-122) ) + sin( radians(37) ) * sin( radians( lat ) ) ) ) AS distance FROM markers HAVING distance < 25 ORDER BY distance LIMIT 0 , 20;
Here's the SQL statement that will find the closest 20 locations that are within a radius of 25 miles to the 37, -122 coordinate. It calculates the distance based on the latitude/longitude of that row and the target latitude/longitude, and then asks for only rows where the distance value is less than 25, orders the whole query by distance, and limits it to 20 results. To search by kilometers instead of miles, replace 3959 with 6371. On 21 Jul., 14:35, ArnMan <[email protected]> wrote: > I am working on a page that has a custom google map, that checks mysql for > current longitude and latitude, and centers the map on that. > I would like to be able to show markers that are a certain distance away > from the center marker, from other locations in the database > I have a mysql database that has locations. and another table that includes > the center location, which changes. I currently have a little green marker > that shows where the center location is, and moves when the long and lat > changes. > Example. > Lets say I am at 0/0 Long/Lat > and I want only the markers shown if their coordinates are within > 5/5 > -5/5 > -5/-5 > 5/-5 > > <https://lh6.googleusercontent.com/-05j9Ez9JLtY/Tigb_FlphjI/AAAAAAAAAB...> > > Is there anyway to use php, or javascript to check inside those coordinates > everytime the page loads and place a marker where is a location? > > Thank you in advance -- You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.
