Hi all,
I’m still novice programmer but I heard about Anvil on the Talk Python podcast and have been really enjoying my time with it.
One issue I’m having is getting InfoWindows to pop-up when clicking a Google map icon. My goal is to have all the icons load in with no InfoWindows and then have the window pop-up above the icon when a user clicks on the icon.
Right now I have only one Form (MainPage) and a Module (MarkingModule). I’m using a database of longitude & latitude coordinates to place icons on the map using a simple for loop. In the for loop I’m assigning an event handler for a “click” on the icon. The issue comes when defining the marker_click function. If I pass arguments to the marker_click function they all fire off “automatically” and if I don’t I’m getting an error.
I resorted to just using the lat/lng coordinates of each point on click to search my data table and pop-up an alert with the information I want, but this is what I would like to do long term.
I’m open to any and all suggestions and I will answer any questions.
RELEVANT CODE:
MainPage
class MainPage (MainPageTemplate):
def __init__(self, **properties):
# You must call self.init_components() before doing anything else in this function
self.init_components(**properties)
# Any code you write here will run when the form opens.
def autolocate_btn_click (self, **event_args):
# This method is called when the button is clicked
self.main_map.clear()
MarkingModule.auto_mark_self(self.main_map)
MarkingModule.mark_all(self.main_map)
def locationsubmit_btn_click (self, **event_args):
# This method is called when the button is clicked
self.main_map.clear()
MarkingModule.manual_mark_self(self.main_map, self.location_txt.text)
MarkingModule.mark_all(self.main_map)
MARKING MODULE
def mark_all(main_map):
for row in app_tables.mastertable.search(Gender="G"):
girl_marker = GoogleMap.Marker(
animation=GoogleMap.Animation.DROP,
position=GoogleMap.LatLng(row['Latitude'],row['Longitude']),
icon="http://icons.iconarchive.com/icons/icons-land/vista-map-markers/64/Map-Marker-Bubble-Pink-icon.png",
title=row['Name']
)
main_map.add_component(girl_marker)
girl_marker.set_event_handler("click", marker_click)