Google Maps Solar API: Getting "404 Entity Not Found" for Specific Buildings, How to Check Available Areas?

598 Views Asked by At

I've been trying to experiment with the new Google Maps Solar API to assess solar potential for various buildings. However, I've encountered a consistent issue where I receive a "404 Entity Not Found" error message for certain buildings I'm interested in. Strangely, my API access seems to be functional as I can successfully query buildings in larger cities. Is there a method to determine the geographical areas where the Solar API is applicable and which buildings are accessible? It's puzzling because I know my access is working, but the error is persistent for specific structures. Any insights or guidance on debugging this problem would be greatly appreciated.

I tried using the example in the docs, this lat / long is working. Buildings in bigger cities are working but none in my area.

2

There are 2 best solutions below

2
Tom Rigter On

Check wheter or not your building is in a HIGH or MEDIUM region (https://developers.google.com/maps/documentation/solar/coverage?hl=en). In your API request you can change the requiredQuality according to where your building is situated.

0
brassmookie On

The Google Solar API response seems to be unfortunately lacking at the moment. As another commenter has already alluded to, your location needs to be in an area of HIGH or MEDIUM coverage in order to receive an API response. However, as you have already discovered, if your location is not in a coverage area the API response will be a very uninformative error. Specifically (at least in my case) the following error:

{
  "error": {
    "code": 403,
    "message": "Requests from referer \u003cempty\u003e are blocked.",
    "status": "PERMISSION_DENIED",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.ErrorInfo",
        "reason": "API_KEY_HTTP_REFERRER_BLOCKED",
        "domain": "googleapis.com",
        "metadata": {
          "service": "solar.googleapis.com",
          "consumer": "projects/x"
        }
      }
    ]
  }
}

This is incredibly unhelpful (and misleading) for most people and it would be much more useful if the API returned an error code such as NOT_FOUND. Hopefully in the future Google will update the API response to something more appropriate.

As for your inquiry about a method to check whether or not a location has solar data available, your best bet at the moment is to just look for and handle the 404 error.

$.getJSON(url, function (data) {
    // building data has been returned
}).fail(function(response) {
    if (response.status == 404) {
        // no building data returned
    }
});