Ad

How Does The Google Maps App Get The Information That A Place Is "Closing Soon"?

In Google Maps, when I navigate to a place like a shop or restaurant, if it will close within the next 60 minutes it says in red Closing Soon, and gives a popup "~ closes at ~pm, you may not arrive in time".

Using what API or service does the Google Maps app get this information? How does it know that a place will be closing soon?

I'm using Google Places API Web Service (https://developers.google.com/places/web-service/intro), and my PHP server can get the Place Details (https://developers.google.com/places/web-service/details), but there is no flag for whether or not it will close soon, and no information about the opening hours from which I could calculate it.

This is an example Place Details response:

   "results" : [
  {
     "geometry" : {
        "location" : {
           "lat" : 37.415994,
           "lng" : -122.0771611
        },
        "viewport" : {
           "northeast" : {
              "lat" : 37.41711577989273,
              "lng" : -122.0758283701073
           },
           "southwest" : {
              "lat" : 37.41441612010728,
              "lng" : -122.0785280298927
           }
        }
     },
     "icon" : "https://maps.gstatic.com/mapfiles/place_api/icons/shopping-71.png",
     "id" : "67563858da6146557fe7bc66b596d735b2946adb",
     "name" : "7-Eleven",
     "opening_hours" : {
        "open_now" : true
     },
     "photos" : [
        {
           "height" : 588,
           "html_attributions" : [
              "\u003ca href=\"https://maps.google.com/maps/contrib/103288427379633317891/photos\"\u003e7-Eleven\u003c/a\u003e"
           ],
           "photo_reference" : "CmRZAAAARCuoZMJvsKOXHwJmj4Eyu6UEqfRec6c3lnUxaL6dEVnMlWl02TKKkPEBb06ZpxAAow5tZZH3OYGshnjChBjhyyaB3WXxI_5DP0eRoJBag1IRVGs028hci-iFNAJceIHkEhC6fmFFKrURt2SVVMZPKnk-GhSceJbHEG_vIWrsq6UZbUjBuK7bgg",
           "width" : 864
        }
     ],
     "place_id" : "ChIJ0Ttxbla3j4ARCpH-PwldBRo",
     "plus_code" : {
        "compound_code" : "CW8F+94 Mountain View, California",
        "global_code" : "849VCW8F+94"
     },
     "price_level" : 1,
     "rating" : 3.4,
     "reference" : "CmRbAAAA50y6X4iUisNQl4Nu-457gKMfcxfIF1PNcon9xlqfir29nvEiHkcQOzoW-yghDbq3n_Ktz7HDcO4zrxgZAUwbLK3Ur9d-6vmyA8pAGHRFyoDV4eqtuT-x5hwYJMHmMSDaEhAf0WA4izKuormbIfu-pqCeGhRsmtZeRrwiJ5P32pyOdlp_ylc5xQ",
     "scope" : "GOOGLE",
     "types" : [
        "convenience_store",
        "store",
        "food",
        "point_of_interest",
        "establishment"
     ],
     "vicinity" : "1380 Pear Ave, Mountain View"
  }

Is this information private and only available to Google apps? Or can my service access it for my app? I need to know whether a place is closing soon.

EDIT: There is opening_hours, but it usually comes back like this:

"opening_hours" : {
    "open_now" : true
},

I've tested it for a restaurant that will close soon. The Google Maps app shows it as Closing Soon from 1 hour before it will close, while opening_hours remains true with no additional information until the last minute it is open.

Ad

Answer

What opening_hourscan contain is described here: https://developers.google.com/places/web-service/details?hl=en#PlaceDetailsResults

So either the info was never added for the place you mention in your question, or there is an issue with the data. In any case, we can't do anything about it. If you believe there is an issue with the data, you should contact Google. Nobody can do anything about it here.

Here is an example of a place that returns all data: https://jsfiddle.net/upsidown/yfawx50v/

That said, with the Place ID ChIJ0Ttxbla3j4ARCpH-PwldBRo you gave in your example, I do not get the same results:

  "opening_hours" : {
     "open_now" : true,
     "periods" : [
        {
           "open" : {
              "day" : 0,
              "time" : "0000"
           }
        }
     ],
     "weekday_text" : [
        "Monday: Open 24 hours",
        "Tuesday: Open 24 hours",
        "Wednesday: Open 24 hours",
        "Thursday: Open 24 hours",
        "Friday: Open 24 hours",
        "Saturday: Open 24 hours",
        "Sunday: Open 24 hours"
     ]
  },

I get all details, as expected, and clear information about the fact that it's open 24/7, which I believe makes sense for a 7-Eleven.

Ad
source: stackoverflow.com
Ad