百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
K

kivy-gmaps

> 编程语言
开源

Kivy 应用程序内的 Google 地图集成

100 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

Kivy 应用程序内的 Google 地图集成

Kivy / Google Maps integration

Example that shows how to integrate Google Maps within a Kivy application. Currently works only on Android.

Work in progress

Configuration

  • Configure your package.name and package.domain. The sum of both should not be more than 20 characters, or Google Maps API will not work:

      package.name = kivygmaps
      package.domain = com.mr
    
  • Follow the Android Maps API v2 documentation to get your Android Maps API key

  • Put your API Key into buildozer.spec in [app:android.meta_data] section as com.google.android.maps.v2.API_KEY:

      [app:android.meta_data]
      com.google.android.maps.v2.API_KEY = YOURAPIKEYHERE

Usage

The gmaps module provide a GMap widget that you can directly use into your application. Right now, you can add only one GMap per application, on an transparent background. If you cover the background, the widget will not be shown. Here is an hello world example:

…

Threads

All the operation done on the map must be done within the internal thread of the android widget. It means, you cannot interact directly from Kivy. You can create object (LatLng, Marker..), but interact with the map must stay in the map thread.

All the event fired by the GMap are happening in the map thread. For example, if you bind to the GMap.on_map_click, your callback will be already in the map thread. If you want to call a method within the map thread, you can use GMap.execute() method. You cannot return values from it, and the call will be asynchronous:

python
map = GMap()
def my_func(...):
    pass
map.execute(my_func)

You can also decorate your function with android.runnable.run_on_ui_thread, or GMap.run_on_ui_thread:

python
from android.runnable import run_on_ui_thread

@run_on_ui_thread
def set_position(self, lat, lng):
    pos = self.map_widget.create_latlng(lat, lng)
    self.map_widget.map.moveCamera(
        self.map_widget.camera_update_factory.newLatLngZoom(
        pos, 13))

When the Android Google Maps widget is created, it will fire an event name on_ready. This is where you can create markers, change the camera, and so on.

Events

Supported Google Maps events are:

  • on_camera_change(CameraPosition) (not working yet)
  • on_info_window_click(Marker)
  • on_map_click(LatLng)
  • on_map_loaded() (not working yet)
  • on_map_long_click(Marker)
  • on_marker_click(Marker)
  • on_marker_drag(Marker)
  • on_marker_drag_end(Marker)
  • on_marker_drag_start(Marker)
  • on_my_location_button_click

All the events are dispatched in the map thread, not the kivy main thread.

Utils

The GMap have some methods to create java object easily, such as:

  • GMap.create_latlng(lat, lng) - Create a LatLng object
  • GMap.create_marker(**options) Create a Marker object, with all the key=value in options

Authors

  • Mathieu Virbel, Melting Rocks
  • Thomas Hansen, Fresk

Issues· 8 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Python

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言