Dynamic Map Markers

I don't want to add a new marker for every new site that comes online. So I reference each site in this loop and try to generate the JSON for the marker. The map throws a "t.map is not a function" error and all the JSON is out of order. I tried lots of methods and searching online but couldn't find any guides for a property like "marker" that has variable length (or I would have just used the expression binding).

Here's my code...


forum.txt (1.0 KB)

Here's what the code returns in the property browser for a marker (there are 60+ markers)...

Here's the reference of what a regular marker looks like I'm aware some of my properties might not be done properly like the colors or "null" not sure if that causes the issue...

Here's the error on the map...
image

I'm very new to the map component apologies if I'm missing something obvious.

1 Like

I would start troubleshooting by just limiting your loop to a single marker for now to see if it's just a marker later in the loop causing issues, or if it will work with just 1. If it works with just 1, then increase your loop in increments until it gets the error as there may be one location that's breaking the entire component.

1 Like


This is the error I'm not getting after reducing it to one marker. I have no idea how to change it from a object to an array using just ignitions scripting?

UPDATE:
Used this post

to make a list and append to it the dictionary and now I'm closer I think but I get a "Cannot read properties of undefined (reading 'content')"

On your return change it to this and see if that fixes it:

return [newDict]

Edit: I see what you're doing now. You need to define newDict before your loop as an empty array

newDict = []

Then you can create a tempDict without the array designation you're trying to do with
newDict[str(count)] = {
to just be

tempDict = {

then replace your counter increment with

newDict.append(tempDict)

Then return it just as you currently are.

1 Like

Yea I tried that and still getting the "cannot read contents error in the post above", I think I need to write the actual dicitonary different somehow.

You don't want to return a dictionary, you want to return a list of markers (which are dictionaries)

not sure what line you're declaring newDict but I think you're declaring it as newDict = {}

I would change it to newList = []
Then on line 34, change that newDict[str(count)] = <your marker dictionary> to newList.append(<your marker dictionary>)

1 Like

Just edited my response. Re-check that and see if that helps.

1 Like

Trying these rn I'll edit this when I'm done. Thanks!
@michael.flagler @Matthew.gaitan
Thanks so much the map isn't showing an error but the marker isn't showing up still sadly.

Heres the new code

tempDict = {
'name': str("GS111111"),
'properties':{},
'enabled': True,
'lat': siteNameLatt,
'lng': siteNameLong,
'opacity': 1,
"icon":{"path": "material/location_on", "color": "#4190F7", 'rotate': 0, 'size':{'width':36,'height':36}, 'style':{}},
'event':{'stopPropagation':False},
'tooltip':{'content':{'text':'','view':{'path':'','params':{}}},'direction':'auto','permanent':False,'sticky':False,'opacity':1},
'popup':{'enabled':False,'content':{'text':'','view':{'path':'','params':{}}},'width':{'max':300,'min':50},'height':{'max':None},
'pan':{'auto':True},'closeButton':True,'autoClose':True,'closeOnEscapeKey':True,'closeOnClick':None}
}

newList.append(tempDict)
return newList

Got the marker to show up by changing the 'null' fields to actual values as I'm not sure how to put an actual null value in. The marker shows up way at the wrong place however, its suppose dto be in texas, I know its the right coordinates bc i use the same values for the map default center and thats right. It does move when i change the lat and long in the code however its way off from where that actually is.

Wait if I reverse latt and long variable in the code it's accurate?

Your Lat & Lng values are backwards

1 Like

That ain't Texas

1 Like