# Display POI on map taken from db and updated in realtime

**URL:** <https://discourse.nodered.org/t/display-poi-on-map-taken-from-db-and-updated-in-realtime/74997>\
**Category:** General\
**Created:** [10 February 2023 15:19 UTC](https://discourse.nodered.org/t/display-poi-on-map-taken-from-db-and-updated-in-realtime/74997 "2023-02-10T15:19:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Elberto](https://avatars.discourse-cdn.com/v4/letter/e/b19c9b/32.png) [@Elberto](https://discourse.nodered.org/u/Elberto)\
**Post date:** [10 February 2023 15:19 UTC](https://discourse.nodered.org/t/display-poi-on-map-taken-from-db-and-updated-in-realtime/74997/1 "2023-02-10T15:19:15Z")

</div>

Hi to all.  
I need to display POI, stored in db, on map but I am a beginner and I have many problems...  
I have POI coordinates and status stored on db, when I load map I need to display POIs regardless status (on status I can read battery voltage and other values), let's say "battery discharged" to be shown as blue icon color.  
Then I receive updates via TCP, so I need to compare received values with db stored ones, if different I need to update both db and icon color.  
If status not received for, let's say 10 minutes, I have to set battery status as "discharged", store it on db and change icon color...  
I have no idea about doing this in node red, now I am just testing TCP server...

Issue:  
I found several examples about using db using inject node but I tried to use function node due to "on start" and "on message" options.  
On my function node:

```auto
msg.topic="SELECT name, lat, lon, type, status FROM stations"
return msg;

```

I correctly get output value from db but I still get error "ReferenceError: msg is not defined" even if the same msg.topic I've found on many examples... so what's wrong?  
I used function node due I suppose placing same code on "on startup" I can see POI displayed first time I load map, but not working.  
I also set inject note to send timestamp "inject once after" as found in some examples... is this best way?

Issue:  
Using inject node "inject once after" I can display current status but I have to distinguish between first read and following. I supposed to use a counter as global variable, right?  
Thanks.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [11 April 2023 15:20 UTC](https://discourse.nodered.org/t/display-poi-on-map-taken-from-db-and-updated-in-realtime/74997/2 "2023-04-11T15:20:06Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
