2

i have the following scenario: 1. i will keep a list of stores locations (coordinates and info) 2. will "feed' relevant info from that list to Google map object 3. the user can search for stores around a given radius from their home 4. the generated map will display markers of stores if any are found.

so far, i'm good.. NOW: after such a map has been generated and markers placed in it, how can i retrieve (hopefully from the Google object) a list of all included stores/markers ? -- the idea here is that my client wants to store the users' address along with the stores close to their home.

any help would be highly appreciated, thanx in advance

samoyed
  • 881
  • 4
  • 13
  • 25

3 Answers3

0

eventually i tackled the issue from another direction: 1. get lat & lng of user's address using geo.getLocations 2. check distance from all stores in Db (lat lng already stored in Db) using a php function 3. write link in html for each store that's within desired radius 4. link opens a window with google map containing address and store location as markers

long story short: First crate the list, THEN display maps.. = no need to try extract data from the map.

i guess there are better ways to go about it - this one did it for me.. i will gladly submit the code in detail to anyone interested. it involves combination of js, php and some jquery ajax.

samoyed
  • 881
  • 4
  • 13
  • 25
0

You want to look for the harvesine formula. The harvesine formula can compute the distance between 2 points. If you can do a query nested with the harvesine formula you select all stores within a given radius.

Micromega
  • 12,486
  • 7
  • 35
  • 72
-1

I would do this:

//points is an array of LatLng items

var bounds = map.getBounds()

for (i=0,len=points.length;i<len;i++) {
  if (bounds.contains(points[i])) {
    //do your stuff with the visible item
  }
}
sth
  • 222,467
  • 53
  • 283
  • 367