How to Add marker over script in map component in perspective

Hi,
can anyone know about how to add a marker in map component in perspective over script
Thanks in advance,
Sri

Hi,
I add markers this way:

markers = []
#Tooltip
TooltipOrientation = 'auto' #top,bottom etc
TooltipView = {'params':{},'path':'path_to_tooltip_view'}#params which are defined on the path_to_tooltip_view. If You have some, so the code have to be: 'params':{'first_param':value_of_the_first_param,'second_param':value_of_the_second_param}
tooltip = {'enabled':True,'content':{'text':'Tooltip Tittle','view':TooltipView},'direction':TooltipOrientation,'permanent':False,'sticky':False,'opacity':1}
#Marker PopUp
MarkerView = {'params':{},'path':'path_to_marker_view'}#params which are defined on the path_to_marker_view
content = {'text':'PopUp text','view':MarkerView}
pan = {'auto':True}
width = {'max':300,'min':50}
height = {'max':300}
IconClasses = {'classes':''}
icon = {'path':'material/place','color':'(0,0,0)','size':{'width':30,'height':30},'style':IconClasses}
popup = {'enabled':False,'content':content,'pan':pan,'closeButton':False,'autoclose':False,'closeOnEscapeKey':False,'closeOnClick':True,'width':width,'height':height}
#Marker
markers.append({'popup':popup,'name':'New Marker','lat':float(59.252521),'lng':float(24.020222),'opacity':1,'icon':icon,'tooltip':tooltip})
self.getSibling("Map").props.layers.ui.marker = markers

Thanks Iscrac, for your response
I tried this script as same in a button pressed state it showing like Global name error sorry for the noob question what does popup means,
image

I edited my code above, so try one more time please. There was a little mistake)

and… as a result You will get nothing until You put these markers to Your map element

Do You know how to do it?

Here’s the screenshots:
Graphic Display

Objects’ Structure in Project Browser:
image

Location of Map’s markers in Perspective Property Editor:

Button Event Script (onClick)

1 Like

Thanks Iscrac That was a great guidance
it worked fine
once again thanks
Warm Regards,
Sri

1 Like

You are welcome! :blush:

1 Like

Hi Israc
i already have 7 markers which i have added manually when i used this script it is overwriting them and only one marker is showing how can i overcome it?
the below pictures shows that how my ui markers changed from and to
image
image

Probably by setting this to the markers you already have

markers = self.getSibling("Map").props.layers.ui.marker

for sure) thanx)
but when I use loops, so I use temporary variable markers = [], and then I send them to map

array.extend(array) probaly should work too
self.getSibling("Map").props.layers.ui.marker.extend(markers)

i dont think this is a good idea tho, as it might keep appending more and more…
idk the usecase, maybe thats what you want…
but i would defining your custom markers in a custom prop and then add them both up into the property

view prop with the predefined static markers
view.custom.staticMarkers = [...]
and then in the script
self.getSibling("Map").props.layers.ui.marker = view.custom.staticMarkers + markers

He asked how to add markers via script
He did't specify what he wants to get in the end as a Result.
There's no exact task)

Thats why it was a suggestion :slight_smile:

i would define the 7 markers somewhere else and then combine them like so
self.getSibling("Map").props.layers.ui.marker = view.custom.staticMarkers + markers

I get it now. sorry for misunderstanding from my side

1 Like

Hi Iscrac,
can i know how to delete those added markers over script
Regards,
Sri Haran

Yeah thats why i said its best to split them up so you know which were added xd

Thank you for the script.
I updated the locations from the database. When I add more locations to DB, the same mark is being updated with the new location. how do we keep the previous marker and create a new marker with the new location?