Search code examples
google-mapsgeolocationmapswifigoogle-geolocation

Google Maps Geolocation API for wifiAccessPoints returns geolocation not found


I am using google API to convert wifi data to location data usng POST Method

https://www.googleapis.com/geolocation/v1/geolocate?key=YOUR_API_KEY

    {

  "considerIp": "false",
 "wifiAccessPoints": [
  {
   "macAddress": "01:23:45:67:89:AB",
   "signalStrength": 8,
   "age": 0,
   "signalToNoiseRatio": -65,
   "channel": 8
  },
 {
   "signalStrength": 4,
   "age": 0
  }
 ]
}

Response I am getting is

{
  "error": {
  "errors": [
   {
    "domain": "geolocation",
    "reason": "notFound",
    "message": "Not Found"
  }
],
"code": 404,
"message": "Not Found"
}
}

This is the same code I had used earlier and I was getting latitude and longitude during testing last month. Suddenly I get this failure response. We even tried for Mac addresses that we have tested before all now return same responses. In above example we are using mac address used in google example. but we also tried the ones that we were getting data before.


Solution

  • 404: Not found error response means that no result were returned. However, your request is valid.

    You should assume that for some cases, the geolocation is going to fail and you should build an exception handling component that does not fail if errors do occur with geolocation. Your application should continue functioning even if the current location was not correctly fetched due to an error or a user denying permission for the browser to provide the location.

    To confirm that this is the issue, set considerIp to false in your request. If the response is a 404, you've confirmed that your wifiAccessPoints and cellTowers objects could not be geolocated.