TomSchimansky / TkinterMapView

A python Tkinter widget to display tile based maps like OpenStreetMap or Google Satellite Images.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Passing text to the marker_click event

rrsc1234 opened this issue · comments

Hi. I am going through the following example code mentioned in this repository:

import tkinter
import tkintermapview

# create tkinter window
root_tk = tkinter.Tk()
root_tk.geometry(f"{1000}x{700}")
root_tk.title("map_view_simple_example.py")

# create map widget
map_widget = tkintermapview.TkinterMapView(root_tk, width=1000, height=700, corner_radius=0)
map_widget.pack(fill="both", expand=True)

def marker_click(marker):
    print(f"marker clicked - text: {marker.text}  position: {marker.position}")

marker_2 = map_widget.set_marker(52.516268, 13.377695, text="abcd", command=marker_click) ## With this line marker is plotted on the map with text placed beside the marker location

custom_text = 'abcd'
marker_3 = map_widget.set_marker(52.546268, 13.878695, text="", command=marker_click) ## Here text is not placed besides the marker position

root_tk.mainloop()

With the above code I am able to place marker_2 at the required location but with the text placed besides the marker location.

What I am looking for is that I want to place marker_3 on the map and I want to pass custom_text as argument to marker_click so as to use custom_text inside marker_click function.

Also please let me know is there any possibility to attach a pop-up window with the marker?