Closed sptrakesh closed 4 years ago
Hey Sptrakesh,
It looks like the rows are wrap with a "location" which it doesn't except. Could you send the query you used, so I can see if it's a problem with the plugin or the query?
And it's currently not possible to have the map center itself based on the points, but should be easy to implement, when I have the time.
Hello,
The data is coming from an Akumuli event stream that is retrieved via a custom JSON datasource, so it will be hard for you to replicate.
When I did not see the data, I inspected the map query control implementation, and it looked like you expect a structure similar to what I have above as well.
https://github.com/alexandrainst/alexandra-trackmap-panel/blob/master/src/map_ctrl.js#L88
If I am reading it right, for each row
in the rows
array, you retrieve the location
object, and within the location
object you verify the type
is geo:json
and that it has a value
property with an array of coordinates
.
If you can share what a valid response should look like (maybe expand the README), I can validate against that. I will also try changing the output in the JSON datasource to be simple latitude
longitude
to see if that works better.
Did a debug build by adding some console output, and now I know why the map shows nothing. Looks like the output is invalid (no errors shown) as far as what Grafana expects. See this screen capture where you can see the query inspector shows the data, but in the map control, during iteration it just sees an array of null
values.
Any idea why Grafana hands over different results to the map control?
Here is the structure that i'm getting from a CrateDB:
[{
columns: [
{ text: "location" },
{ text: "time_index" }
],
rows: [
[
"{\"type\":\"geo:json\",\"value\":{\"coordinates\":[56.18803,10.16773],\"type\":\"Point\"},\"metadata\":{\"timestamp\":{\"type\":\"DateTime\",\"value\":\"2019-12-19T06:35:59.390Z\"}}}",
"2019-12-19T06:35:59Z"
],
[
"{\"type\":\"geo:json\",\"value\":{\"coordinates\":[56.18803,10.16773],\"type\":\"Point\"},\"metadata\":{\"timestamp\":{\"type\":\"DateTime\",\"value\":\"2019-12-19T06:38:44.376Z\"}}}",
"2019-12-19T06:38:44Z"
]
],
type: "table"
}]
It doesn't have to be a json string, here is the string as a object:
{
"type": "geo:json",
"value": {
"coordinates": [56.18803, 10.16773],
"type": "Point"
},
"metadata": {
"timestamp": {
"type": "DateTime",
"value": "2019-12-19T06:35:59.390Z"
}
}
}
The metadata above is not needed for the plugin, it's just part of NSGIv2 data format
Thanks for the samples, that is very helpful. Still not clear how the array without a wrapper location
object works based on line 88 (on master branch) in the map control code. The bigger issue in my case seems to be a mismatch in the data I see in the query inspector vs the data that gets to the map control.
The location
variable, that is used in line 88, is the index in the array that was found from the columns list.
Haven't had any problems with a mismatch between the query inspector and the map controls data. This seems more like a problem with the Grafana and your data source.
The response I get in the query inspector looks a lot different compared to yours:
Thanks for your help. Definitely looks like a datasource issue.
This is most likely a question and not necessarily a bug. I followed the documentation for displaying NGSIv2 data, and through the query inspector and datasource logs I think I see the data being returned as it is supposed to be formatted. However I do not see any points on the map.
Related question is is there a way to automatically have the map centre itself based on range of points being displayed?