Update server location attribute
Simple form to input new location for pre-defined server attribute key.
Who it’s for
Anyone who needs to record where a thing is when the thing cannot say so itself — a fixed sensor whose position was surveyed on installation, an asset placed on a site plan, a piece of equipment moved between buildings. The coordinates are reference data about the entity rather than a stream of readings.
What it does
The Update server location attribute widget presents latitude and longitude fields and writes them to the entity on save. The Get current location button fills both fields from the browser’s own geolocation, which is what makes this practical for a technician standing at the spot with a phone.
- Two fields, one action — coordinates entered or captured together and committed as a pair.
- The current location button removes the transcription step, which is where manual coordinate entry usually goes wrong.
- High accuracy mode can be requested from the browser, trading battery and time for a better fix.
- The key names are configurable, so the widget writes whatever the rest of the dashboard already reads.
- Field labels, their wording, and whether each is required are all configurable.
- Fields lay out in a column or a row, so the form fits a narrow panel or a wide band.
- Stored in server scope, the coordinates stay on the platform, which is exactly right for a position the device has no use for and every map widget does.
- The Update server location attribute widget captures a position: it draws no map, so pairing it with a map widget is what lets anyone confirm the point landed where they meant.
How to set up
Data keys
The Update server location attribute widget writes the two keys named in its settings.
| Attribute | Scope | Operation | Description |
|---|---|---|---|
latitude | Server | Read + Write | The latitude key, named by Latitude key name. Written as attribute. |
longitude | Server | Read + Write | The longitude key, named by Longitude key name. Written as attribute. |
Set the key names to match whatever the map widgets on the dashboard already read. The defaults are latitude and longitude, and a mismatch produces a form that saves successfully while the map stays empty.
Form
| Setting | Default | Effect |
|---|---|---|
| Latitude key name | latitude | The key written for latitude |
| Longitude key name | longitude | The key written for longitude |
| Show button ‘Get current location’ | On | Fills both fields from the browser’s geolocation |
| Use high accuracy | Off | Requests a more precise fix, at the cost of time and battery |
| Show label | On | Prints the field captions |
| Input fields alignment | Column | Stacks the fields or places them side by side |
| Latitude field required | On | Blocks saving without a latitude |
| Longitude field required | On | Blocks saving without a longitude |
| Show result message | On | Confirms the write on screen |
How to customize
- To match the dashboard’s existing keys — set the Latitude key name and Longitude key name.
- To get a better fix in the field — turn on Use high accuracy, which is worth the wait when the position is being surveyed.
- To fit a wide band — set Input fields alignment to Row.
- To word the fields — set the Label for latitude and Label for longitude, or turn labels off on a compact panel.
- To allow a partial entry — turn off the required flags, though a half-set position is rarely useful.
- To word the validation — set the ‘Required’ error message to something that says what is missing.
Tips
- Use server scope for anything stationary. A surveyed position is reference data, and writing it to a scope the device receives puts firmware in the position of being told where it is, which nothing on the device is going to do anything useful with.
- Put a map beside the form showing the same keys. A pair of coordinates is unverifiable by reading it, and a point that landed in the wrong hemisphere because of a sign is obvious on a map and invisible in a text field.
Share Your Widget with the Community
Built a custom widget? Export it as a JSON from ThingsBoard and publish it to the IoT Hub through a simple 4-step wizard (Upload, Listing, Readme, Review & Submit). Share it with thousands of ThingsBoard developers worldwide and get featured in the catalog.