Docs

Map

The Map widget shows pins on a map. Your board sends a latitude and a longitude for each one.

Use it for: a GPS tracker, a delivery bike, sensors spread over a field, the last known position of something that moves.

SettingWhat it does
Pinthe virtual pin your code writes to
Pin to latest pointkeep the view centred on the newest position
Show my locationdraw the phone position too
Satelliteswitch the base map

Open these from the canvas: tap Edit, then long press the widget and choose Configure.

Example

A GPS module reporting a position every ten seconds.

map.ino
#include <PlynxSimpleEsp32.h>

WidgetMap myMap(V22);
PlynxTimer timer;

void sendPosition()
{
  float lat = 45.4642;                // replace with your GPS reading
  float lon = 9.1900;

  myMap.location(1, lat, lon, "Bike");
}

void setup()
{
  Serial.begin(115200);

  // Auto setup: WiFi and the Plynx token are configured from the app.
  //
  // To provide them directly in the sketch instead, use:
  //   Plynx.begin(auth, ssid, pass);
  Plynx.begin();

  timer.setInterval(10000L, sendPosition);
}

void loop()
{
  Plynx.run();
  timer.run();
}

myMap.location(index, lat, lon, label) places one point. The index identifies it: sending the same index again moves that point, a new index adds another.

myMap.clear() removes every point.

Ten seconds suits a vehicle. A tracker on a battery can go much slower, and each message costs power.

Troubleshooting

ProblemCheck
Map is emptythe widget pin and the WidgetMap pin do not match
Points pile up instead of movinga new index each time; reuse the same one
Position lands in the sealatitude and longitude are swapped
Track is jaggedGPS noise; average a few readings before sending

Next