My organizations gets calls when a client installs a weather station. This always includes a latitude and longitude that is then used to record where the station is. The installers generally gets a latitude and longitude from their phone; different people use different services that have different imagery so we like to homogenize it with Google’s. I’ve made a form that has you fill out the Lat/Long and then you press a button/enter to have the map place a marker.
What I would like to be able to do is then set up an event for when the marker’s location is changed that then updates the text in the text fields that will then be saved to a database. I know that is an event listed in the docs: position_changed().
I have no idea how to access it however, I’ve read the docs on events but still really not sure how to trigger it or get the existing map’s marker data.
Thanks, That got me headed in the right direction:
marker.add_event_handler("position_changed", self.marker_position_changed)
def marker_position_changed(self, **event_args):
marker = event_args.get('sender')
print(marker.position) # or store to your database, etc.
This is now printing out the new latitude and longitude that the marker is moved to.