# Auto Updata Map with add up locations

**URL:** <https://forum.inductiveautomation.com/t/auto-updata-map-with-add-up-locations/80424>\
**Category:** Ignition\
**Created:** [October 13, 2023, 2:44am UTC](https://forum.inductiveautomation.com/t/auto-updata-map-with-add-up-locations/80424 "2023-10-13T02:44:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ignitionSL](https://avatars.discourse-cdn.com/v4/letter/i/9e8a1a/32.png) [@ignitionSL](https://forum.inductiveautomation.com/u/ignitionSL)\
**Post date:** [October 13, 2023, 2:44am UTC](https://forum.inductiveautomation.com/t/auto-updata-map-with-add-up-locations/80424/1 "2023-10-13T02:44:39Z")

</div>

Could you please tell me how to make the Map update automatically with the data provide from database (It always update with new location with altitude and longitides)?  
I need to pass data to Alt,Lng and popup window's params.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/2/6224579651143eeddd0bed837f49d7fcec355991.png)

---

<div class="post-metadata">

**Author:** ![Hayden\_Watson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/hayden_watson/32/48792_2.png) [@Hayden\_Watson](https://forum.inductiveautomation.com/u/Hayden_Watson)\
**Post date:** [October 13, 2023, 6:37am UTC](https://forum.inductiveautomation.com/t/auto-updata-map-with-add-up-locations/80424/2 "2023-10-13T06:37:44Z")

</div>

If from the database, you could make a couple named queries to get the lat and long.

And then use query bindings on these values to get those results

---

<div class="post-metadata">

**Author:** ![ignitionSL](https://avatars.discourse-cdn.com/v4/letter/i/9e8a1a/32.png) [@ignitionSL](https://forum.inductiveautomation.com/u/ignitionSL)\
**Post date:** [October 15, 2023, 9:34pm UTC](https://forum.inductiveautomation.com/t/auto-updata-map-with-add-up-locations/80424/3 "2023-10-15T21:34:06Z")

</div>

I want to make it when the database is added with a new location/data. Is there any way?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 15, 2023, 10:35pm UTC](https://forum.inductiveautomation.com/t/auto-updata-map-with-add-up-locations/80424/4 "2023-10-15T22:35:35Z")

</div>

> [@ignitionSL](#):
>
> make it when the database is added with a new location/data

You generally cannot "subscribe" to changes in a database with vanilla JDBC. You have to arrange to "poll" the database for changes in some way. (Not always easy to make performant--may involve DB triggers saving notifications in a special pollable table.)

---

<div class="post-metadata">

**Author:** ![Hayden\_Watson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/hayden_watson/32/48792_2.png) [@Hayden\_Watson](https://forum.inductiveautomation.com/u/Hayden_Watson)\
**Post date:** [October 16, 2023, 8:15am UTC](https://forum.inductiveautomation.com/t/auto-updata-map-with-add-up-locations/80424/5 "2023-10-16T08:15:27Z")

</div>

Depends on how often this database table is updated and how urgent this value is. When I've done similiar stuff before the table rarely updated and it was just for reference, so I just had a query tag that was a leased tag mode, it would poll every 5 minutes when not displayed and every 10 seconds when on a mimic.

That way to the user it will appear to update after a short delay, like some of the tags we displayed on that system.

If it updates much more often, you may need a more complicated system where the database splits the data into a new table every month or week (to reduce query time) and then poll it much faster, like every second and that will get you as close to a live value as is really possible. Or do as Phil says and have some other notification table.

---

<div class="post-metadata">

**Author:** ![ignitionSL](https://avatars.discourse-cdn.com/v4/letter/i/9e8a1a/32.png) [@ignitionSL](https://forum.inductiveautomation.com/u/ignitionSL)\
**Post date:** [October 17, 2023, 11:00pm UTC](https://forum.inductiveautomation.com/t/auto-updata-map-with-add-up-locations/80424/6 "2023-10-17T23:00:29Z")

</div>

I did it using binding(Query) to the marker.  
Here is the code.

```auto
	'markers =[]'
	'pydata = system.dataset.toPyDataSet(value)'
	tooltip = {'enabled':False,'direction':'auto','permanent':False,'sticky':False,'opacity':1}
		
	for row in pydata:
		power = '{:.1f}'.format(row['Power']) # limit decimal points |#'{:.2f}'.format(5.39120)
		power1 = str (power) + " MW" # MW
		
		status= (row['Status']) #Status of the site
				
		markers.append({'lat':(row['Latitude']*0.001),'lng':(row['Longitude']*0.001),'opacity':1,'riseOnHover':False,'riseOffset':250,
		'icon':{'path':'material/location_on','color':'#149DEE' if status == True else '#888888' ,'size':{'width':36,'height':36}},
		'tooltip':tooltip,
		'popup':{'enabled':False,'content':{'path':"", 'view': {'path':'Objects/Map_Popup','params':{'P_name': (row['Asset_Name']), 'powerV':power1, 'Status': "Running" if status == True else "Fault" , 'P_Type': row['SiteType'] }}},'width':{'max':150,'min':110},
		'height':{'max':100,'min':90},'pan':{'auto':True},'closeButton':True,'autoClose':True,'closeOnEscapeKey':True}})    
		
		
		
		self.getSibling("TextArea").props.text = markers
	
	#if( (row['Status'])== true) : Status1= "Running'
	return markers

```

I used 'transaction groups' to update the database.
