In this section , I will explain how to implement Geolocation using Scala and Lift . You can easily fetch user’s current location or near by location by his IP address .
1) You will need API key to be able to use . To get API key , just Go to IPInfoDB .
2) Get user’s IP address
var ipAddress: String = "" S.containerRequest.map(r => ipAdd = r.remoteAddress)
val key:String = "Your API Key "
var ipInfoDBURL = new URL("http://api.ipinfodb.com/v3/ip-city" + "/?key=" + key + "&ip=" + ipAddress + "&format=" + "json") val conn = ipInfoDBURL.openConnection
will provide you JSON with all details including latitude and longitude .