Last updated by admin 2 years ago
grails install-plugin geoip
Last updated by dalew75 2 years ago
The purpose of this very simple plugin is to provide a seemless integration with MaxMind's geographical location open source API and has been built to be used with the GeoCity binary database.
Usage:
1) You must configure 2 properties in your Config.groovy:
- Path to your Maxmind database file. You can get a free Lite version here: http://www.maxmind.com/app/geolitecity. You must define one of the following:
- geoip.data.path = "/opt/geoip/GeoLiteCity.dat" - The path to the database on the file system ]
- geoip.data.resource= "/WEB-INF/GeoLiteCity.dat" - The path to the database, which is bundled as a resource in the war file ]
- geoip.data.cache - There are 4 possible values for this:
- 0 - GEOIP_STANDARD
- 1 - GEOIP_MEMORY_CACHE
- 2 - GEOIP_CHECK_CACHE
- 4 - GEOIP_INDEX_CACHE
Note that when you're using the cached versions it will load the database in memory. Its size is usually around 45 MB.
2) At the moment the service exposes only one method. Here is how you determine the location of an IP:
class MyController {
def geoIpService
def index = {
def location = geoIpService.getLocation("88.158.9.150")
render location.countryName + " " + location.city
}
}Here is a list of the location's fields.
Note that some may not be properly populated if the information is missing.
- countryCode
- countryName
- region
- regionName
- city
- postalCode
- timezone
- latitude
- longitude
- dmaCode
- areaCode
- metroCode
Last updated by burtbeckwith 2 years ago
Q: Why is this useful?
A: Here is what I think:
- You can sell your customers very detailed statistics regarding the viewers of their products
- You can implement a very good targeted ad engine (customers can choose to display their commercials only for German people located in region 5 for example)
- If you're building a map driven application, you can position your users on their home area
Last updated by admin 2 years ago