Skip to content

Commit 8c2eedc

Browse files
Added gifs and last changes
1 parent cb4e765 commit 8c2eedc

File tree

3 files changed

+49
-19
lines changed

3 files changed

+49
-19
lines changed
Loading
Loading

content/arduino-cloud/06.features/12.advanced-map/content.md

+49-19
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,25 @@ tags: [Arduino Cloud, Map, GPS, Location]
77

88
The **advanced map widget** is used to track the location of a cloud Thing and draw a path between the different logged points. You can track the data in both real time, select from a specific time period while selecting the variables you want to display.
99

10-
![The advanced chart widget.](assets/advanced-chart.gif)
10+
![The advanced map widget.](assets/world-map.gif)
1111

1212
This widget can be added onto existing projects (if you are already tracking location), and is particularly interesting to use in projects such as:
1313
- Weather stations,
1414
- Environmental data stations,
15+
- Monitoring fleets,
16+
- Any project requiring localization of devices,
1517
- Various science projects where location tracking is needed.
1618

17-
This widget can use variables from **different Things**, so you can monitor data from various devices and plot it all in one place.
18-
19-
For example, you could set up a series of sensors around a city, and measure the CO2 emissions from your phone or laptop in a single chart!
20-
2119
## Hardware & Software Needed
2220

2321
- [Arduino Cloud](https://app.arduino.cc/).
2422
- Cloud compatible boards, [see full list](https://docs.arduino.cc/arduino-cloud/guides/overview#compatible-hardware).
2523

24+
***In this tutorial, we use the [MKR WiFi 1010](/hardware/mkr-wifi-1010) and [MKR GPS Shield](/hardware/mkr-gps-shield) for tracking latitude and longitude. This is not a requirement, you can use any board for this tutorial.***
25+
2626
## Setup & Configuration
2727

28-
To use the advanced map widget, you will need to set up a Thing and a variable that you want to track. This variable needs to be a `location` type.
28+
To use the advanced map widget, you will need to set up a Thing and a variable that you want to track. This needs to be a `location` type variable.
2929

3030
***If you are unfamiliar with how to set up a Thing and variables, head on over to the [Getting Started with the Arduino Cloud](/arduino-cloud/guides/overview) article.***
3131

@@ -39,46 +39,76 @@ To use the advanced map widget, you will need to set up a Thing and a variable t
3939

4040
**4.** After selection, your variables will appear in the right panel, with a number of configuration options. You can for example choose how the track between logged locations will be represented (line, spline, spline area, line area and bar). You can also change the icon of the pin on the map.
4141

42-
![Advanced chart widget configuration.](assets/widget-config.png)
42+
![Advanced map widget configuration.](assets/widget-config.png)
4343

4444
**5.** Click on **"Done"** when finished selecting the variable. If your board is connected and is sending data to the Cloud, you will see the widget's location data update frequently.
4545

4646
## Example Code
4747

48-
The sketch of your project does not require much complexity. In your automatically generated code, simply add the location tracking code inside of the loop. :
48+
The sketch of your project does not require much complexity. In your automatically generated code, simply add the location tracking code inside of the loop. We are using the [Arduino_MKRGPS](https://www.arduino.cc/reference/en/libraries/arduino_mkrgps/) library. We only needed to add these following lines to the loop to track the things location and send it to the advanced map widget:
4949

5050
```arduino
51+
if (GPS.available()) {
52+
// read GPS values
53+
float latitude = GPS.latitude();
54+
float longitude = GPS.longitude();
55+
advancedMap = Location(latitude, longitude);
56+
}
57+
```
58+
59+
The full sketch used is found below:
5160

61+
```arduino
62+
#include <Arduino_MKRGPS.h>
63+
#include "thingProperties.h"
64+
65+
void setup() {
66+
Serial.begin(9600);
67+
delay(1500);
68+
69+
initProperties();
70+
71+
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
72+
73+
setDebugMessageLevel(2);
74+
ArduinoCloud.printDebugInfo();
75+
}
76+
77+
void loop() {
78+
ArduinoCloud.update();
79+
if (GPS.available()) {
80+
// read GPS values
81+
float latitude = GPS.latitude();
82+
float longitude = GPS.longitude();
83+
advancedMap = Location(latitude, longitude);
84+
}
85+
}
5286
```
5387

5488
## Usage
5589

5690
With the widget set up, let's explore some of its features.
5791

58-
### Value Tracking
92+
### Location Tracking
93+
94+
When tracking the location with the "Live" setting the current location of the device will be marked with a pin, then a track will be drawn between its previous location and its current location.
5995

60-
Hover over a line to see what the value of a variable was in a specific point in time. In this case, we choose to check only the temperature and the humidity.
96+
![View values.](assets/location-tracking.gif)
6197

62-
![View values.](assets/advanced-chart.gif)
98+
Picking one of the other time frame options will show the locations of the device during that specific time frame.
6399

64100
### Specific Time Period
65101

66102
To see a specific time period, click on the calendar icon, where you can select the starting & end time & date.
67103

68104
![Select time & date.](assets/select-time-frame.png)
69105

70-
As an example, the widget below shows the illuminance (LUX) recorded via the **MKR ENV Shield**, the `light` variable.
71-
72-
Here, we can see that sunset occurred around 18.00 (6PM), and sunrise sometime around 07.00 (7AM).
73-
74-
![Light tracking.](assets/light-tracking.png)
75-
76106
## Limitations
77107

78-
The following variables are not supported in the advanced chart widget.
108+
The following variables are not supported in the advanced map widget.
79109

80110
-
81111

82112
## Summary
83113

84-
The advanced chart widget can be used for **any** project that includes location tracking. It is perfect for scientific projects when monitoring the location of the cloud Thing over time is needed.
114+
The advanced map widget can be used for **any** project that includes location tracking. It is perfect for scientific projects when monitoring the location of the cloud Thing over time is needed.

0 commit comments

Comments
 (0)