Google Maps Configuration with 3rd gen devices (Argon,Boron, Xenon)


#1
// This #include statement was automatically added by the Particle IDE.
#include <google-maps-device-locator.h>

GoogleMapsDeviceLocator locator;
void locationCallback(float lat, float lon, float accuracy);

void setup()
{
    Serial.begin(9600);
    while (!Serial.available()) delay(100);
    Serial.println("Setup - Device Locator");
    // Scan for visible networks and publish to the cloud every 60 seconds
    // Pass the returned location to be handled by the locationCallback() method
    Serial.println("Setup - subscribe with locationCallback");
    locator.withSubscribe(locationCallback);
    Serial.println("Setup - locator runs every 60 seconds");
    //locator.withLocateOnce();
    locator.withLocatePeriodic(60);
}
// subscription handler
// Handle the returned location data for the device. This method is passed three arguments:
// - Latitude
// - Longitude
// - Accuracy of estimated location (in meters)
void locationCallback(float lat, float lon, float accuracy)
{
    Serial.printlnf("Lat: %f Lon: %f Acc (m): %f", lat, lon, accuracy);
}

void loop()
{
    delay(1000);
    Serial.println("Loop - locator.loop called every second");
    locator.loop();
}

I am trying to track the location of my devices and input them on a map, also what’s the best way to save the location data to analyze and get insights from!


#2

You can store the lat and lon on the device and then send an event when the values change or update Particle variables. Remember to convert the float to double to include as a Particle variable. You could set up a webhook to post the location to a google sheet or some other service that can receive and plot on a map the lat and lon.