{"id":15532862,"url":"https://github.com/tito/kivy-gmaps","last_synced_at":"2025-04-23T13:41:53.994Z","repository":{"id":11605017,"uuid":"14098201","full_name":"tito/kivy-gmaps","owner":"tito","description":"Google maps integration within Kivy application","archived":false,"fork":false,"pushed_at":"2017-04-18T21:43:35.000Z","size":1898,"stargazers_count":102,"open_issues_count":8,"forks_count":26,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-04-23T13:41:51.569Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tito.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-11-04T02:09:05.000Z","updated_at":"2025-04-03T16:16:51.000Z","dependencies_parsed_at":"2022-09-04T12:02:07.916Z","dependency_job_id":null,"html_url":"https://github.com/tito/kivy-gmaps","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tito%2Fkivy-gmaps","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tito%2Fkivy-gmaps/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tito%2Fkivy-gmaps/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tito%2Fkivy-gmaps/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tito","download_url":"https://codeload.github.com/tito/kivy-gmaps/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250440784,"owners_count":21431056,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-02T11:33:29.242Z","updated_at":"2025-04-23T13:41:53.978Z","avatar_url":"https://github.com/tito.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Kivy / Google Maps integration\n==============================\n\nExample that shows how to integrate Google Maps within a Kivy application.\nCurrently works only on Android.\n\n**Work in progress**\n\n![ScreenShot](https://raw.github.com/tito/kivy-gmaps/master/screenshot.png)\n\nConfiguration\n-------------\n\n* Configure your `package.name` and `package.domain`. The sum of both should\n  not be more than 20 characters, or Google Maps API will not work:\n\n        package.name = kivygmaps\n        package.domain = com.mr\n\n* Follow the [Android Maps API v2 documentation](https://developers.google.com/maps/documentation/android/start#the_google_maps_api_key) to get your Android Maps API key\n* Put your API Key into buildozer.spec in `[app:android.meta_data]` section as\n  `com.google.android.maps.v2.API_KEY`:\n\n        [app:android.meta_data]\n        com.google.android.maps.v2.API_KEY = YOURAPIKEYHERE\n\nUsage\n-----\n\nThe `gmaps` module provide a `GMap` widget that you can directly use into your\napplication. Right now, you can add only one GMap per application, on an\ntransparent background. If you cover the background, the widget will not be\nshown. Here is an hello world example:\n\n```python\nimport gmaps\nfrom kivy.app import App\n\nclass HelloGmaps(App):\n    def build(self):\n        self.map_widget = GMap()\n        self.map_widget.bind(on_ready=self.create_some_markers)\n        return self.map_widget\n\n    def create_some_markers(self, map_widget):\n        # get the google map interface\n        sydney = map_widget.create_latlng(-33.867, 151.206)\n        marker = map_widget.create_marker(\n            title='Sydney',\n            snippet='The most populous city in Autralia',\n            position=sydney)\n        map_widget.map.addMarker(marker)\n\nif __name__ == '__main__':\n    HelloGmaps().run()\n```\n\n### Threads\n\nAll the operation done on the map **must** be done within the internal thread\nof the android widget. It means, you cannot interact directly from Kivy. You\ncan create object (LatLng, Marker..), but interact with the map must stay in\nthe map thread.\n\nAll the event fired by the `GMap` are happening in the map thread. For example,\nif you bind to the `GMap.on_map_click`, your callback will be already in the\nmap thread. If you want to call a method within the map thread, you can use\n`GMap.execute()` method. You cannot return values from it, and the call\nwill be asynchronous:\n\n```python\nmap = GMap()\ndef my_func(...):\n    pass\nmap.execute(my_func)\n```\n\nYou can also decorate your function with `android.runnable.run_on_ui_thread`, or `GMap.run_on_ui_thread`:\n\n```python\nfrom android.runnable import run_on_ui_thread\n\n@run_on_ui_thread\ndef set_position(self, lat, lng):\n    pos = self.map_widget.create_latlng(lat, lng)\n    self.map_widget.map.moveCamera(\n        self.map_widget.camera_update_factory.newLatLngZoom(\n        pos, 13))\n```\n\nWhen the Android Google Maps widget is created, it will fire an event name\n`on_ready`. This is where you can create markers, change the camera, and so on.\n\n### Events\n\nSupported [Google Maps events](https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/GoogleMap) are:\n\n* `on_camera_change(CameraPosition)` (not working yet)\n* `on_info_window_click(Marker)`\n* `on_map_click(LatLng)`\n* `on_map_loaded()` (not working yet)\n* `on_map_long_click(Marker)`\n* `on_marker_click(Marker)`\n* `on_marker_drag(Marker)`\n* `on_marker_drag_end(Marker)`\n* `on_marker_drag_start(Marker)`\n* `on_my_location_button_click`\n\nAll the events are dispatched in the map thread, not the kivy main thread.\n\n### Utils\n\nThe GMap have some methods to create java object easily, such as:\n\n* `GMap.create_latlng(lat, lng)` - Create a [LatLng](https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/model/LatLng) object\n* `GMap.create_marker(**options)` Create a [Marker](https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/model/Marker) object, with all the key=value in options\n\n## Authors\n\n- Mathieu Virbel, [Melting Rocks](http://meltingrocks.com/)\n- Thomas Hansen, [Fresk](http://fresklabs.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftito%2Fkivy-gmaps","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftito%2Fkivy-gmaps","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftito%2Fkivy-gmaps/lists"}