Child pages
  • Geo Location Services

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Summary

Excerpt

The Geo Location Services is an app that once installed offers a web service that receives an IP value and returns a two-character ISO 3166-1 country code in which that IP resides. With this app you can enable Geo IP functionalities in your apps. For example you can choose which content to show to your users based on the country they are located.

This app uses Maxmind GeoLite2 Country CSV database. You download that database from here http://dev.maxmind.com/geoip/geoip2/geolite2/#Downloads and then use an interface that is also provided by this app to import that data into Liferay. You won't need to use an external service anymore to provide Geo IP functionalities in your portal. 

Installation

The installation steps are as follows:

  • Obtain the Geo Location Services app from the Liferay Marketplace.
  • Deploy the app in your existing Liferay installation. If you haven’t installed Liferay, please download and follow the instructions to do so.
  • Download Maxmind GeoLite2 CSV databases from here: www.maxmind.com. Be sure to download the GeoLite2 version and not the GeoIP2 version. The direct link is this: http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country-CSV.zip
  • Access Control Panel -> Configuration -> Geo Location Services and upload the corresponding files


  • A notification in the dockbar will be sent after the process it's completed, in the meantime you can continue using Liferay.



Usage

To view the JSON web services for the Geo Location Services app, access the following link [portal]:[port]/geo-location-services-portlet/api/jsonws e.g http://localhost:8080/geo-location-services-portlet/api/jsonws

 

To use this service in your portlets or templates use this code:


<script type="text/javascript">
Liferay.Service(
  '/geo-location-services-portlet.geolocations/get-location',
  {
    IP: '8.8.8.8'
  },
  function(obj) {
    alert(obj);
  }
);
</script>

 

or if you prefer to use JQuery use this one:

<script type="text/javascript">

    $.get( "/api/jsonws/geo-location-services-portlet.geolocations/get-location/IP/8.8.8.8", function(data, status) {

        alert(data);

    });

</script>

If the IP value is not valid or if can't be found in the database it will return an empty String ("") value.

Code repository

The latest source code is located at the following location:

https://github.com/rivetlogic/liferay-geo-location-services

Contact Us

We welcome feature/bug reports concerning the Geo Location Services app. Discussion helps to clarify the ways the app can be used and also helps define directions for future development. Please post your concerns at http://issues.rivetlogic.com/browse/LRA

 

Change log:

1.1.0

New feature: Help page.

1.2.0

Company credits.