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

Customising MapMarker and MapMarker Popup with canvas to include text. #56

Open
Codename-Nase opened this issue May 15, 2022 · 0 comments

Comments

@Codename-Nase
Copy link

Codename-Nase commented May 15, 2022

Hi all.
I tried creating a RoundRaisedButton with text, and then use it as a MapMarker and MapMarkerPopup itself instead of using an icon with source.
Creating the Button worked fine as shown below:

`from kivy.lang import Builder
from kivy.uix.behaviors import ButtonBehavior
from kivymd.uix.boxlayout import MDBoxLayout
from kivymd.app import MDApp
from kivymd.uix.behaviors import (
CircularRippleBehavior,
FakeCircularElevationBehavior,
)

KV = '''
:
size_hint: None, None
size: "25dp", "25dp"
radius: self.size[0] / 2
md_bg_color: 1, 0, 0, 1
MDLabel:
text: "[b]DC[/b]"
markup: True
halign: "center"
valign: "center"
size: root.size
pos: root.pos
font_size: root.size[0] * .6
theme_text_color: "Custom"
text_color: [1] * 4
MDScreen:

CircularElevationButton:
    pos_hint: {"center_x": .5, "center_y": .6}
    elevation: 4

'''

class CircularElevationButton(
FakeCircularElevationBehavior,
CircularRippleBehavior,
ButtonBehavior,
MDBoxLayout,
):
pass

class Example(MDApp):
def build(self):
return Builder.load_string(KV)

Example().run()`

But after adding it as a child widget under MapView to replace the regular MapMarkerPopup, the text became redundant. I don't know if i am not doing it right, or otherwise.
Below is a code of how I have tried implementing it with MapView, and any helpful pointer towards a better solution will be very much appreciated.

`from kivy.lang import Builder
from kivy.uix.behaviors import ButtonBehavior
from kivy.garden.mapview import MapMarkerPopup
from kivymd.uix.boxlayout import MDBoxLayout
from kivymd.app import MDApp
from kivymd.uix.behaviors import (
CircularRippleBehavior,
FakeCircularElevationBehavior,
)

KV = '''
:
size_hint: None, None
size: "25dp", "25dp"
radius: self.size[0] / 2
md_bg_color: 1, 0, 0, 1
MDLabel:
text: "[b]DC[/b]"
markup: True
halign: "center"
valign: "center"
size: root.size
pos: root.pos
font_size: root.size[0] * .6
theme_text_color: "Custom"
text_color: [1] * 4

MapView:
lat: 10
lon: 10
zoom: 5
CircularElevationButton:
lat: 12
lon: 12
elevation: 5
'''

class CircularElevationButton(
MapMarkerPopup,
FakeCircularElevationBehavior,
CircularRippleBehavior,
ButtonBehavior,
MDBoxLayout,
):
pass

class Example(MDApp):
def build(self):
return Builder.load_string(KV)

Example().run()`

Below is an image of what i am trying to replicate as a Marker
Screenshot 2022-05-14 at 09 56 33
.

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