Skip to content

WebNinjaDeveloper.com

Programming Tutorials




Menu
  • Home
  • Youtube Channel
  • Official Blog
  • Nearby Places Finder
  • Direction Route Finder
  • Distance & Time Calculator
Menu

Python 3 Tkinter Google Maps API Example to Display Maps & Markers Using TkinterMapView Library

Posted on January 17, 2023

 

 

Welcome folks today in this blog post we will be using the google maps api inside the tkinter gui window and we will be placing markers using the tkintermapview library. All the full source code of the application is shown below.

 

 

Get Started

 

 

In order to get started you need to install the below library using the pip command as shown below

 

 

pip install tkintermapview

 

 

After that we need to make an app.py file and copy paste the following code

 

 

app.py

 

 

Python
1
2
3
4
5
6
7
8
import tkinter
from tkintermapview import TkinterMapView
 
root_tk = tkinter.Tk()
 
root_tk.title("map_view_simple_example.py")
 
root_tk.geometry(f"{600}x{400}")

 

 

As you can see we are importing the tkintermapview library at the top and then we are setting the title of the gui window and then we are setting the geometry which is the width and height of the gui window.

 

 

Python
1
2
3
widgetmap_widget = TkinterMapView(root_tk, width=600, height=400, corner_radius=0)
 
widgetmap_widget.pack(fill="both", expand=True)

 

 

As you can see we are initializing the TkinterMapView library and inside that we are passing the width and height. And then we are adding this tkintermapview into the gui window using the pack() method.

 

 

Python
1
2
3
widgetmap_widget.set_tile_server("https://mt0.google.com/vt/lyrs=m&hl=en&x={x}&y={y}&z={z}&s=Ga", max_zoom=22)
widgetmap_widget.set_address("Wellington New Zealand", marker=True)
root_tk.mainloop()

 

 

As you can see we are setting the src of the map widget and then we are setting the address of the map widget and based upon this address we are plotting the red markers on the map. And then we are starting the tkinter app.

 

 

 

Recent Posts

  • Android Java Project to Crop,Scale & Rotate Images Selected From Gallery and Save it inside SD Card
  • Android Kotlin Project to Load Image From URL into ImageView Widget
  • Android Java Project to Make HTTP Call to JSONPlaceholder API and Display Data in RecyclerView Using GSON & Volley Library
  • Android Java Project to Download Youtube Video Thumbnail From URL & Save it inside SD Card
  • Android Java Project to Embed Google Maps & Add Markers Using Maps SDK
  • Angular
  • Bunjs
  • C#
  • Deno
  • django
  • Electronjs
  • java
  • javascript
  • Koajs
  • kotlin
  • Laravel
  • meteorjs
  • Nestjs
  • Nextjs
  • Nodejs
  • PHP
  • Python
  • React
  • ReactNative
  • Svelte
  • Tutorials
  • Vuejs




©2023 WebNinjaDeveloper.com | Design: Newspaperly WordPress Theme