Automatic marker in map

I would like to know how to generate markers to apply on the map, automatically, so as not to repeat the step every time

Automatically from what?

1 Like

from code, i use this for example

def runAction(self, event):
	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

I have to develop this code for an indefinite number of markers

What is the source of the "indefinite number of markers"?

Go to the map component, props.layers.ui.marker, and add a binding. Use the binding to bring in the source of the markers. Add a transform script that loops through the results and returns appropriately formatted marker JSON objects.

3 Likes

I want to use a for loop to generate multiple markers, how do I do this?

Please explain more about what you're doing, because it doesn't make sense to me.

If you're using a for loop to generate these markers...what tells you how many markers to make? How do you know where to put each marker?

1 Like