diving further into kivy, i began to wonder what map options were available (either google maps or something like open street maps). What i found so far:
KivyMaps link So far the most usefull Module i found. It is supposed to work on mac, windows, android and iOS (experimental), BUT: i don't find the docs anywhere! I googled a lot, still i have not a clue how to use kivyMaps
Kivy Mapview link Available trough garden. Good docs, but they say it works only on android. For me, it does work on Kivy + Mac, at least displaying and moving the map. Setting coordinates and changing them does not.
So i guess my question is: What do you use? Are there other options available that i missed? Where are the KivyMaps docs (can somebody provide examples?)
Whether a static or interactive map, mobile or browser-based, with the Google Maps Platform you can integrate customizable maps into shops, websites, apps, and business software.
Google Maps Integration Services. Google Maps is a web mapping service provided by Google. It offers satellite imagery, street maps and street view perspectives. It also offers functions such as route planner for travelling by foot, car, bicycle and with public transportation.
For Kivy desktop applications you have another option for maps. You can use CEF Python to embed a web browser in your Kivy App. You can direct this browser to an HTML file that loads web based maps.
In order to use CEF Python, you'll have to install the module cefpython3. I'm pretty sure you can install this using:
kivy -m pip install cefpython3
otherwise, you can use a traditional pip install
and move the module into a location where kivy can access it.
From this sample code, I made the following example by changing the start_url
of the web browser like:
start_url="file://"+GetApplicationPath("testMaps.html")
Where testMaps.html
is an HTML file with this Google Maps's sample code (the HTML + JavaScript version).
The Kivy code that I'm running is long and kind of complicated because CEF Python takes a lot of configuring... I probably don't need all the code that's in there, but I haven't tried slimming it down yet.
EDIT: updated link for the kivy code at the bottom of this answer
Yeah... pretty beefy. The HTML file will have to be in the same directory as the above code for it to work properly. Also, I put this together on a Mac, and some things might be different on Windows and Linux. Although the sample code I started with was written for Linux, so it could be that just the Windows folks will run into trouble.
If you've gotten the code to run and you're wondering what the forward and back buttons are for; that's just legacy from the example code I used as a base, and has nothing to do with the map.
Last note: I used Google Maps for this example, but with this method you could use any web based mapping utility.
Here is an updated link to the file: https://drive.google.com/file/d/0B3003wRVnBn2cGZvcHhoWi04d0E/view?usp=drivesdk&resourcekey=0-3Xh_HbqtT07aO2r4uZmP6A
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With