1

When people visit my web site, I want get the user's IP, then locate the city on google map and show information relevant to the visitor's city.

What gems can help me? Or give me some advice. Thanks.

Trott
  • 66,479
  • 23
  • 173
  • 212
mlzboy
  • 14,343
  • 23
  • 76
  • 97

2 Answers2

1

Rather than getting the user's IP, especially if you expect most of the users will be mobile/handheld users, you might be better off using JavaScript Geolocation and Google Maps Reverse Geocoding. See http://dev.w3.org/geo/api/spec-source.html and http://code.google.com/apis/maps/documentation/javascript/services.html#ReverseGeocoding.

On the other hand, if you really do want to use the user's IP, check out Center Google Map Based on geocoded IP.

There may be Gems that wrap these services up for you, but if not, they're fairly straightforward.

Community
  • 1
  • 1
Trott
  • 66,479
  • 23
  • 173
  • 212
0

The Geocoder gem will help you. This Railscast explains how you can use Geocoder.

Mischa
  • 42,876
  • 8
  • 99
  • 111