Wednesday 4 June 2014

Real-time mapping of your trip with SPOT and CartoDB

In my last blog post, we saw how we could synchronize data from a SPOT unit to a CartoDB table. Today, I wanted to test if the system worked. As I'm currently staying on a small island, long hikes are very limited, so I decided to go around the island with my kayak. It takes me about an hour.

GPS studies on a small island can be extremely hard :-)

Before I started my journey, I created a new shared page on my SPOT account. I also adjusted the tracking interval on my SPOT to 5 minutes, which would give me about 12 locations around the island.

The shared page need to be "Active" to have access to the location feed. 

This gave me an URL to a public map (valid for 7 days only!): 

It's not the best design I've seen, but it works. We'll soon create our own map. 
The map URL also gave me the feed id: "0pGqOT43h6tTRcGJujqltqRYE3rHNu6db". With this id we have access to a feed with our locations, updated real-time:
https://api.findmespot.com/spot-main-web/consumer/rest-api/2.0/public/feed/0pGqOT43h6tTRcGJujqltqRYE3rHNu6db/message.json

I've made a copy as the locations will be deleted after 7 days:


I also started my cron job from last blog post, so the location data was automatically synced to my CartoDB-account. I'm including the feed id in my spot location table, so I can have store multiple trips in the same table by filtering on the id:

SELECT * FROM spot WHERE feed_id = '0pGqOT43h6tTRcGJujqltqRYE3rHNu6db'

Then it was easy to create a simple map in CartoDB just showing the locations:

In the next blog post, we'll create a more custom map experience with Leaflet. Stay tuned!


No comments: