Issue with mapping multiple locations

I am trying to set up a dashboard that takes in location and weather data generated on a raspberry pi (contained in the same mqtt topic and retrieved in a single query) and displays the weather data at each location on a map. At present I am only trying to display 2 locations (Kelowna and Stockholm)

using the following query:

from(bucket: “pidata”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “IOT”)
|> filter(fn: (r) => r[“_field”] == “city” or r[“_field”] == “humidity” or r[“_field”] == “lat” or r[“_field”] == “lon” or r[“_field”] == “outside_humidity” or r[“_field”] == “outside_temp” or r[“_field”] == “temperature”)
|> aggregateWindow(every: v.windowPeriod, fn: last, createEmpty: false)
|> yield(name: “last”)

and applying the merge transformation, both locations appear correctly on the map, but the tooltip for each is a list of every published message:

If I apply the reduce fields transformation with the last calculation, only the most recent message is displayed (which is what I want), but only the second of the two locations (Stockholm) shows up:

I would like for both locations to show on the map, but for the tooltip to show only the last measurements for that location.

I suspect that this issue has to do with how the data is formatted before being sent to Grafana, but I’m unsure what to change to make it work. If anyone has any suggestions I would appreciate it.

EDIT: I’m also curious if there’s a way to have the tooltip for each location link to a different dashboard. The ‘See Location Details’ link in each tooltip is the same, but I would like each location to have a separate ‘Details’ dashboard.