How to use the Geolocation API and Integrate with Google Maps?
Geolocation API call returns network location parameters, such as LAC and CELLID. In order to retrieve geographical coordinates, calls to external databases (which store LAC/CELLID to GEO coordinates data mapping data) should be executed. Coordinates returned will point to a cell tower location, depending on cell density distance to the device may vary from dozens of meters (city) to several kilometres (rural area).
Example below is showing how to perform Geolocation API call and use retrieved data to call Google Maps (Google API requires separate subscription):
# authenticate to SIM for Things API to get AccessToken for further requests
POST https://sft.bics.com/api/login (Refer to API doc)
# call to SIM for Things API to get network location info
GET https://sft.bics.com/api/locationInfo?imsi=yourIMSI (Refer to API doc)
Response will contain cell id and network data (note down mcc, mnc, cellid, tac values):
{
"Response": {
"resultParam": {
"resultCode": "10084",
"resultDescription": "Location Info - Success"
},
"resultCode": "0",
"responseParam": {
"imsi": "your_imsi",
"geolocation": {
"cellIdRatType": "4G",
"locationInfoAge": "0",
"mcc": "206",
"mnc": "01",
"cellId": "46135558",
"tac": "9340",
"countryName": "Belgium",
"operatorName": "Proximus-- Societe Anonyme de Droit Public (mobile)"
}
},
"responseId": "62292676207873570",
"responseTimestamp": "11/12/2020 12:27:42"
}
}
# get coordinates from google API
POST https://www.googleapis.com/geolocation/v1/geolocate?key=your_key
JSON body should contain value from precedent API query:
{
"cellTowers": [{
"cellId": 46135558,
"locationAreaCode": 9340,
"mobileCountryCode": 206,
"mobileNetworkCode": 1
}]
}
Response will contain geographical coordinates (lat, lng):
{
"location": {
"lat": 51.0201809,
"lng": 3.6634590000000005
},
"accuracy": 1304
}
# display position on Google Maps
http://www.google.com/maps/place/51.0201809,3.6634590000000005 (latitude followed by longitude, comma separated)
Dropped pin will display cell tower position:
