B4J Question Location (LAT/LON) from fixed network

labcold

Member
Licensed User
Longtime User
I am producing a PC based version of a B4A Android mobile app and I want to include the fixed network based location (LAT.LON) for compatibility. In the Android app I use RSfluffylocation and that works great but I haven't found an equivalent for B4J [if there is one then GREAT please let me know].
SO instead I started looking at using ipinfo web service which is simple and seems to provide reasonably accurate information BUT I am stuck as to how to implement this using any version of the HTTPutils libraries. {my client will not allow the use of Google services btw which would have been easier}

I know the HTML & Java code:
HTML:
<!DOCTYPE html>
<html>
<head>
<title>page Title</title>
<meta charset="utf-8">
</head>

<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script language="Javascript" src="http://www.codehelper.io/api/ips/?js"></script>

<script language="javascript">
/* IPinfo.io */
$.get("http://ipinfo.io", function (response) {
    $("#ip").html("IP: " + response.ip);
    $("#address").html("Location: " + response.city + ", " + response.region);
    $("#details").html(JSON.stringify(response, null, 4));
}, "jsonp");
</script>

<body>
<h3>Client side IP geolocation using ipinfo.io</h3>
<hr/>
<div id="ip"></div>
<div id="address"></div>
<hr/>Full response: <pre id="details"></pre>
</body>
</html>
returns:
Client side IP geolocation using ipinfo.io
IP: 122.53.214.xxx
Location: Mandaluyong,
Full response:
{
"ip": "122.53.yyy.xxx",
"hostname": "122.53.yyy.xxx.static.pldt.net",
"city": "Mandaluyong",
"region": "",
"country": "PH",
"loc": "14.5832,121.0410",
"org": "AS9299 Philippine Long Distance Telephone Company"
}

and "loc": "14.5832,121.0410" is EXACTLY what I want to retrieve.

However I have looked through all the examples and I cannot see how I build the java script and send it to the server with a GET request and then extract the data from the return packet.

I would truly appreciate if someone could put me out of my misery and either point me at an example or a library that would help - this is the only thing I am struggling with in over 3000 lines of code - everything else transferred across simply :D
 
Top