grafana / worldmap-panel

Worldmap panel plugin for Grafana 3.0 that can be overlaid with circles for data points.
MIT License
305 stars 201 forks source link

Add support for Leaflet Marker and Polyline #38

Open syssi opened 7 years ago

syssi commented 7 years ago

I'm trying to draw a GPS track. Connected markers by a polyline instead of circles would be awesome.

Kind regards,

Sebastian

daniellee commented 7 years ago

What's a GPS track? Could you explain a little more?

syssi commented 7 years ago

I'm talking about a path of coordinates recorded by a GPS receiver. For example something like this: http://stackoverflow.com/questions/33468905/draw-lines-between-markers-in-leaflet

hl68fx commented 7 years ago

This would be an awesome feature! :) I forgot to mention that support for longitude and latitude coordinates would be great in combination with leaflet marker and polyline.

daniellee commented 7 years ago

Could you give an example of how you would use this? How would you map it to time series data? I'm not sure I follow how connected markers would map to a graphite/Influx query.

@hl68fx What do you mean by support for longitude and latitude coordinates? Having a data point per coordinate pair would explode most time series dbs. Even Elasticsearch has to geohash coordinates to create aggregations as high precision geohash cell queries can have a very negative effect on performance.

hl68fx commented 7 years ago

I would like to have a column for longitude, a column for latitude and one for time in my database. In Grafana I would like to see a map like Google Maps where I can zoom in. In the right corner I would like to be able to choose a time range. Then Grafana shows me a map where I can see how my Arduino with GPS and GSM modem has moved for example the last 6 hours. Just like the timeline in Google Maps where I can see where I moved at which time: https://cnet3.cbsistatic.com/img/mhl3KrwEsp-POBJrHSGkZw1iH1Q=/2015/07/30/80ed1d14-9ae3-4ad2-ab8a-93f5077ed6ef/googlemapstimeline.jpg This could be really useful for fleet management, tracking your own car, dog, cat, bicycle, parcels,...

samhatchett commented 7 years ago

this sounds like a reasonable and useful thing to do. generalizing, we're talking about spatially plotting the movement of a set of unique "things", where a thing's location is a time-variant property ... rather than the "metric" property being spatially fixed and temporally aggregated. In InfluxDB parlance, the geohash would need to be a 'field', rather than a 'tag'. There's probably better language to use that's Grafana-specific so forgive my poor vocabulary.

this is very similar to plotting a f(t) series on a graph, in that successive location-values are joined by a line, but instead of showing a one-dimensional value versus time, we would be showing a two-dimensional location with time range as a parameter.

daniellee commented 7 years ago

Thank you for all the examples! This is a case where I would accept a PR for this but it is not on the roadmap for the next couple of months.

tkurki commented 7 years ago

I would be happy enough with just having circles on the map that make up the track. That way coloring the circles to reflect some measurement is much easier.

I have yet to store any reasonable amounts of geohashes in InfluxDb, but querywise things look pretty good:

>   select first(navigationPosition) as pos, mean(navigationSpeedThroughWater) as stw from signalk WHERE time > now() - 1h group by time(1m)
name: signalk
-------------
time            pos     stw     
1479640860000000000 ud9tk255vhjj    2.625805687203794
1479640920000000000 ud9tk44bx4h4    2.756186440677968

Even Elasticsearch has to geohash coordinates to create aggregations as high precision geohash cell queries can have a very negative effect on performance

We are not talking about querying by position, just retrieving the data by time range so essentially the db is returning strings. I have no exprience how well InfluxDb handles that for large amounts of data. In my case I can limit the sample rate easily to something like a sample a minute or 30 seconds.

Aggregation is a challenge. So far I've thought about justfirst() in InfluxDb, as averaging track coordinates doesn't really work - if you have rounded a mountain / island in an hour is the representative value for that hour in the middle of the mountain / island or just the point where you were in beginning/middle/end of that time period? My hunch is that just picking first() will work ok.

See https://bost.ocks.org/mike/simplify/ for a way to simplify / aggregate a polyline.

tkurki commented 7 years ago

A further functionality would be to be able to click/hover a point in the and have that point in time highllighted in the graph panels on the dashboard.

tkurki commented 7 years ago

FYI I decided to just hack something together from scratch. The code is a mess but it works:

image

gesaleh commented 7 years ago

Hi can you explain how the data was shown on the map I have a table of alerts that contain the lat and lon I want to display the last alert for each unique device Is this possible?

tkurki commented 7 years ago

See https://github.com/tkurki/grafana-track-map

bmagistro commented 4 years ago

While looking for a solution I stumbled across, https://github.com/pR0Ps/grafana-trackmap-panel and didn't see it referenced here yet. I have not had a chance to look into it yet.