Plugins You can find out about all the publicly available Grails plugins.

Grails GeoIP Plugin

  • Authors: Radu Andrei Tanasa, Alexey Zhokhov, Alexey Zhokhov
  • Organization: Polusharie
3 votes
compile "org.grails.plugins:geoip:0.3.3"

 Documentation  Source  Issues


This plugin facilitates grails integration with the opensource GeoIP framework offered by MaxMind. Using its straightforward API one can find out the country, area, city, geographical coordinates and others based on an IP.

This product includes GeoLite data created by MaxMind, available from


Add the following to your grails-app/conf/BuildConfig
plugins {
	compile ':geoip:0.3.2'

Then run following command to download GeoLite database from MaxMind website

grails install-geo-data

Update Notes (from 0.3.1 and earlier)

Dynamic method isInXXX() changed to isInCountry(XXX).



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.


The plugin adds dynamic methods to your controllers to determine location of client is accessing the app:

isInCountry(String code) (where code is ISO 3166 Country Code) will be true if the client use IP from this country.

def list() {
    if (isInCountry('US')) {
        render(view: 'usa')
    } else {
        render(view: 'default')

Additionally, you can run code conditionally, with access to the current com.maxmind.geoip.Location instance, with this method:

withLocation(Closure closure)

def list() {
    def view = 'list'
    withLocation { location ->
        view = "list_${location.countryCode}"
    render(view: view, model: [list: listInstance])

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
  • city
  • postalCode
  • latitude
  • longitude
  • dma_code
  • area_code
  • metro_code

Copyright and license

Copyright 2009-2013 Radu Andrei Tanasa, Alexey Zhokhov under the GNU Lesser General Public License, version 2.1.

This product includes GeoLite data created by MaxMind, available from