kivy-garden / mapview

Mapview is a Kivy widget for displaying interactive maps.
https://kivy-garden.github.io/mapview/
MIT License
87 stars 29 forks source link

MBTilesMapSource crashes #40

Open jussikiova opened 4 years ago

jussikiova commented 4 years ago

I'm trying to bring an mbtiles-map to MapView. When trying to run the code MBTilesMapSource crashed with following error

[...] File "/home/jussi/Työpöytä/Jennin_homma/jennijenni.py", line 8, in build map_source = MBTilesMapSource("map.mbtiles") File "/home/jussi/.local/lib/python3.8/site-packages/kivy_garden/mapview/mbtsource.py", line 47, in init cx = (bounds[2] + bounds[0]) / 2.0 TypeError: 'map' object is not subscriptable

I checked the lines in question:

    if "bounds" in metadata:
        self.bounds = bounds = map(float, metadata["bounds"].split(","))
    if "center" in metadata:
        cx, cy, cz = map(float, metadata["center"].split(","))
    elif self.bounds:
        cx = (bounds[2] + bounds[0]) / 2.0
        cy = (bounds[3] + bounds[1]) / 2.0
        cz = self.min_zoom

It is obvious that in elif-branch of the if-statement, a map-object is referenced by an index, which leads to the crash. I got my application working by turning the map-object to a list-object.

    if "bounds" in metadata:
        self.bounds = bounds = map(float, metadata["bounds"].split(","))
    if "center" in metadata:
        cx, cy, cz = map(float, metadata["center"].split(","))
    elif self.bounds:
        self.bounds = bounds = list(bounds)                      #ADDED
        cx = (bounds[2] + bounds[0]) / 2.0
        cy = (bounds[3] + bounds[1]) / 2.0

To Reproduce Try to run the MBTilesMapSource with following .mbtiles file

https://drive.google.com/file/d/1rdPAwFW-bx943vQEFGIazMoHE7Pgwtic/view?usp=sharing

Platform System: Kernel: 5.4.0-48-generic x86_64 bits: 64 compiler: gcc v: 9.3.0 Desktop: Cinnamon 4.6.7 wm: muffin dm: LightDM Distro: Linux Mint 20 Ulyana base: Ubuntu 20.04 focal

Python 3.8.2

MapView 1.0.5

Kivy 2.0.0rc3

Best regards,

jussikiova commented 3 years ago

Now I'm having trouble with this project on Buildozer. The same bug persist there and I've got no idea where it gets its code. Not locally, I presume?

ibobalo commented 2 years ago

this bug was fixed long time ago, but fix was rejected by authors, have no idea why.

https://github.com/kivy-garden/mapview/pull/38/commits/a84a17b724e280f8f06da04d7248e471d0c49122

paapu88 commented 6 months ago

Well, I get the same issue after 4 years... Is this package maintained anymore? OOps: correction: looking at the source it seems to have been corrected, so I have my own problems here...