building_selection_tool/map_view_simple_example.py

28 lines
976 B
Python

import tkinter
import tkintermapview
# create tkinter window
root_tk = tkinter.Tk()
root_tk.geometry(f"{1000}x{700}")
root_tk.title("Building Selection Tool")
# create map widget
map_widget = tkintermapview.TkinterMapView(root_tk, width=1000, height=700, corner_radius=0)
map_widget.pack(fill="both", expand=True)
# set other tile server (standard is OpenStreetMap)
map_widget.set_tile_server("https://mt0.google.com/vt/lyrs=m&hl=en&x={x}&y={y}&z={z}&s=Ga", max_zoom=22) # google normal
# map_widget.set_tile_server("https://mt0.google.com/vt/lyrs=s&hl=en&x={x}&y={y}&z={z}&s=Ga", max_zoom=22) # google satellite
# set current position and zoom
map_widget.set_position(45.497059, -73.578451, marker=False) # Berlin, Germany
map_widget.set_zoom(11)
# set current position with address
# map_widget.set_address("Berlin Germany", marker=False)
def marker_click(marker):
print(f"marker clicked - text: {marker.text} position: {marker.position}")
root_tk.mainloop()