In this video I’ll show you how to add a map to your Kivy App.

We’ll use MapView to add a map to our Kivy app two different ways; on the Python file, and on the Kivy file.

Adding maps to our kivy app with MapView is super easy. It allows you to pinpoint locations by Latitude and Longitude.

#kivy #codemy

Python Code: map.py
GitHub Code: map.py

from kivymd.app import MDApp
from kivy_garden.mapview import MapView


class MapViewApp(MDApp):
	def build(self):
		mapview = MapView(zoom=10, lat=36, lon=-115)
		return mapview


MapViewApp().run()


Python Code: map2.py
GitHub Code: map2.py

from kivy.lang import Builder
from kivymd.app import MDApp


class MainApp(MDApp):
	def build(self):
		self.theme_cls.theme_style = "Dark"
		self.theme_cls.primary_palette = "BlueGray"
		return Builder.load_file('map2.kv')
		



MainApp().run()

Kivy Design Code: map2.kv
GitHub Code: map2.kv

#:import MapView kivy.garden.mapview.MapView

MapView:
	lat: 36
	lon: -115
	zoom: 10
		
			

John Elder

John is the CEO of Codemy.com where he teaches over 100,000 students how to code! He founded one of the Internet's earliest advertising networks and sold it to a publicly company at the height of the first dot com boom. After that he developed the award-winning Submission-Spider search engine submission software that's been used by over 3 million individuals, businesses, and governments in over 42 countries. He's written several Amazon #1 best selling books on coding, and runs a popular Youtube coding channel.

View all posts

Add comment

Your email address will not be published. Required fields are marked *

John Elder