0

I have a list of companies with addresses, and user, that send claims (also set their own location).

And I need to send email only for that companies which are in 20 miles near the user. How can I do that?

ValeriiVasin
  • 8,628
  • 11
  • 58
  • 78

1 Answers1

1

Not sure why you want to use Google Maps, since you are sending emails and not displaying locations on the map, right?

I think your best answer is to convert the addresses into latitude and longitude using a geocode service, and then throw them into Mongo or other DB that supports geospatial indexing.

So in Mongo DB after geocoding, you need to convert each address into something like:

{email: 'foobar@foobar.com', address: 'address', loc : { lon : 40.739037, lat: 73.992964 } }

After that you can query the DB to pull out emails for the user, in Mongo it would be something like:

db.emails.find( { loc : { $near : [50,50] } } ).limit(20)

https://developers.google.com/maps/documentation/geocoding/

http://www.mongodb.org/display/DOCS/Geospatial+Indexing

Allyl Isocyanate
  • 13,306
  • 17
  • 79
  • 130