Google Maps Device Locator Problems

I’m trying to get the Google Maps Device Locator working…

  • I setup the Google API account and enabled the geolocation API
  • I created the Google Maps integration in the Particle Console
  • When I click the “test” it reports correctly (lat, long, accuracy) in the event log

I duplicated the sample code and modified it to this:

#include <google-maps-device-locator.h>

  GoogleMapsDeviceLocator locator;

  float glat;
  float glon;
  float gaccuracy;

  void setup() {
    // Scan for visible networks and publish to the cloud every 30 seconds
    // Pass the returned location to be handled by the locationCallback() method

  void locationCallback(float lat, float lon, float accuracy) {
    // Handle the returned location data for the device. This method is passed three arguments:
    // - Latitude
    // - Longitude
    // - Accuracy of estimated location (in meters)
    glat = lat;
    glon = lon;
    gaccuracy = accuracy;

  void loop() {
    //delay (30000);
    char locate_data[128];
    snprintf(locate_data, sizeof(locate_data), "{\"latitude\":\"%.15f\",\"longitude\":\"%.15f\",\"accuracy\":\"%.2f\"}", glat, glon, gaccuracy);
    Particle.publish("locate_data", locate_data, PRIVATE);
    delay(10000); // to ensure adhering to rate limit

But when I run it I consistently get 404 errors from the Google API…

Does anyone have any ideas? I have had this work, but it’s intermittent at best…
It also seems to take some time to respond to the request if it does work, or even if it errors… Is there a way to wait until a value is returned before publishing?


404 error appears if there are no location details stored for the AP address. The location gets into Google’s database if someone with a Android phone connects to the AP - when this has happened and how long it takes to get into the database is a bit of mystery. Is this the first time you have run the code on a photon on the AP it is connected to?

I also got the same errors. This is due to quotas for Geolocation API. The daily quota for Geolocation API is by default 1 if it’s not linked to billing accounts. So to resolve this error increase your quota of daily requests of Geolocate API by enabling billing account.