Reputation: 14721
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.
Upvotes: 1
Views: 232
Reputation: 43318
The Geocoder gem will help you. This Railscast explains how you can use Geocoder.
Upvotes: 0
Reputation: 70163
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.
Upvotes: 1