Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClusteredMarkerLayer bug report #66

Open
jbc0708 opened this issue May 2, 2024 · 0 comments
Open

ClusteredMarkerLayer bug report #66

jbc0708 opened this issue May 2, 2024 · 0 comments

Comments

@jbc0708
Copy link

jbc0708 commented May 2, 2024

Describe the bug
in example file("clusted_geojson.py"), when I changed marker_layers argument,
error happend...

To Reproduce

try to auto center the map on the source

from kivy.base import runTouchApp
from kivy.uix.label import Label
import sys

if __name__ == '__main__' and __package__ is None:
    from os import path
    sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))

from kivy_garden.mapview import MapView, MapMarker, MapMarkerPopup
from kivy_garden.mapview.geojson import GeoJsonMapLayer
from kivy_garden.mapview.clustered_marker_layer import ClusteredMarkerLayer
from kivy_garden.mapview.utils import haversine, get_zoom_for_radius

source = sys.argv[1]

options = {}
layer = GeoJsonMapLayer(source=source)
lon, lat = layer.center
options["lon"] = lon
options["lat"] = lat
min_lon, max_lon, min_lat, max_lat = layer.bounds
radius = haversine(min_lon, min_lat, max_lon, max_lat)
zoom = get_zoom_for_radius(radius, lat)
options["zoom"] = zoom

view = MapView(**options)
view.add_layer(layer)

marker_layer = ClusteredMarkerLayer(
    cluster_radius=200
)
view.add_layer(marker_layer)
count = 0
def create_marker(feature):
    global count
    geometry = feature["geometry"]
    if geometry["type"] != "Point":
        return
    lon, lat = geometry["coordinates"]
    # I want to able to click MapMarker, so cls changed from Marker to MarkerPopup..
    marker_layer.add_marker(lon, lat, cls=MapMarkerPopup)
    # and add to widget in Popup, But error happend.. in below code
    marker_layer.cluster_markers[-1].cls.add_widget(Label(text="Hello"))
    count += 1

layer.traverse_feature(create_marker)
if count:
    print("Loaded {} markers".format(count))

runTouchApp(view)

create marker if they exists

Expected behavior
when I see markerpopup, I will click this and I will show popuped text like "Hello"

Logs/output
Traceback (most recent call last):
File "C:\Users\User\project\MapApp\app.py", line 52, in
layer.traverse_feature(create_marker)
File "C:\Users\User\project\MapApp\env\Lib\site-packages\kivy_garden\mapview\geojson.py", line 254, in traverse_feature
func(feature)
File "C:\Users\User\project\MapApp\app.py", line 47, in create_marker
marker_layer.cluster_markers[-1].cls.add_widget(Label(text="Hello"))
TypeError: MapMarkerPopup.add_widget() missing 1 required positional argument: 'widget'

Platform (please complete the following information):

  • OS: Windows 11
  • Python version: 3.11.7
  • kivy_garden.mapview: 1.0.6

Additional context
If I don't change Mapmarker to MapMarkerPopup, it works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant