Can I configure multiple properties in the Perspective Property editor through a single query binding?
I need to configure the properties of a marker on a map (data is transferred through a database) and need to create a new marker for every new entry to the database.
Please refer to the image
Yes, add the script transform to the binding that returns an array of marker dictionaries.
So, loop through your data return from the query, construct the dictionary with the required properties and values and append that to the list. Then just return that list.
markers = []
for i in range(value.getRowCount()):
markers.append({
"name": i,
"properties": {},
"enabled": True,
"lat": value.getValueAt(i,"column1"),
"lng": value.getValueAt(i,"column2"),
"opacity": 1,
"icon": {
"path": "material/location_on",
"color": "#4190F7",
"rotate": 0,
"size": {
"width": 36,
"height": 36
},
"style": {
"classes": ""
}
},
"event": {
"stopPropagation": False
},
"tooltip": {
"content": {
"text": "",
"view": {
"path": "",
"params": {}
}
},
"direction": "auto",
"permanent": False,
"sticky": False,
"opacity": 1
},
"popup": {
"enabled": False,
"content": {
"text": "",
"view": {
"path": "path/to/my/view",
"params": {
"param1": "value1"
}
}
},
"width": {
"max": 300,
"min": 50
},
"height": {
"max": None
},
"pan": {
"auto": True
},
"closeButton": True,
"autoClose": True,
"closeOnEscapeKey": True,
"closeOnClick": None
}
})
return markers
1 Like
I got this error.

markers = []
for i in range(value.getRowCount()):
markers.append({
"name": "ll",
"properties": {},
"enabled": True,
"lat": value.getValueAt(i,"Latitude"),
"lng": value.getValueAt(i,"Longitude"),
"opacity": 1,
"icon": {
"path": "material/location_on",
"color": "#4190F7",
"rotate": 0,
"size": {
"width": 36,
"height": 36
},
"style": {
"classes": ""
}
},
"event": {
"stopPropagation": False
},
"tooltip": {
"content": {
"text": "",
"view": {
"path": "",
"params": {}
},
}
"direction": "auto",
"permanent": False,
"sticky": False,
"opacity": 1
},
"popup": {
"enabled": False,
"content": {
"text": "",
"view": {
"path": "Objects/Map_Popup",
"params": {
"powerV": 500
}
}
},
"width": {
"max": 300,
"min": 50
},
"height": {
"max": None
},
"pan": {
"auto": True
},
"closeButton": True,
"autoClose": True,
"closeOnEscapeKey": True,
"closeOnClick": None
}
})
return markers
Your first line below the 'for' statement is not indented like it is @william.bowen's example. Sometimes indentation can get messed up when copying and pasting code, so you'll want to always double check this as Python is particular about it.
3 Likes