I am creating an android application using kivy.garden.mapviev, I want the user to be able to move the marker (hero icon) with buttons. when I add an int value to the value dumped from string to float, I convert the result back to string. when i try to do this i get an error. I execute the entire application code in one file, screen manager is a string in the file as screen_helper
when i try to execute the code get the error given in the subject. I'm new to: kivy / kivyMD, below application code and screenshots :.
screen_helper = """
ScreenManager:
UsersPlayGameOnMap:
<UsersPlayGameOnMap>:
name: 'screenmapmove'
MapView:
id: mapview
lat: 40.41362602642995
lon: -3.6819590868909984
zoom:19
max_zoom : 19
min_zoom :19
MapMarkerPopup:
id: player_position
source: "img/myicons/heromenuicon.png"
lat: 40.41362602642995
lon: -3.6819590868909984
MDIconButton :
icon : "apps-box"
pos_hint: {'center_x':0.1,'center_y':0.1}
user_font_size : 40
on_press: root.manager.current = 'UserPlatformFunctions'
MDIconButton :
id : up
icon : "arrow-up-bold-box-outline"
pos_hint : {'center_x':0.5,'center_y':0.18}
user_font_size : 40
on_press: root.buttonUP()
MDIconButton :
id : down
icon : "arrow-down-bold-box-outline"
pos_hint : {'center_x':0.5,'center_y':0.1}
user_font_size : 40
on_press: root.button_DOWN()
MDIconButton :
id : right
icon : "arrow-right-bold-box-outline"
pos_hint : {'center_x':0.65,'center_y':.1}
user_font_size : 40
on_press: root.button_RIGHT()
MDIconButton :
id : left
icon : "arrow-left-bold-box-outline"
pos_hint : {'center_x':0.35,'center_y':0.1}
user_font_size : 40
on_press: root.button_LEFT()
"""
LATI=40.41362602642995
LONDI=-3.6819590868909984
SETTING = True
class UsersPlayGameOnMap(Screen):
def buttonUP(self):
self.pressUP = True
self.pressDOWN = False
self.pressLEFT = False
self.pressRIGHT = False
self.LoadPlayerObject()
def button_RIGHT(self):
self.pressRIGHT = True
self.pressDOWN = False
self.pressUP = False
self.pressLEFT = False
self.LoadPlayerObject()
def button_LEFT(self):
self.pressLEFT = True
self.pressRIGHT = False
self.pressDOWN = False
self.pressUP = False
self.LoadPlayerObject()
def button_DOWN(self):
self.pressDOWN = True
self.pressUP = False
self.pressLEFT = False
self.pressRIGHT = False
self.LoadPlayerObject()
def LoadPlayerObject(self):
if SETTING == False:
self.player_pos_pion = self.localpion
self.player_pos_poz = self.localpoz
if SETTING == True:
self.ids.mapview.lat = LATI
self.ids.mapview.lon = LONDI
self.player_pos_pion = LATI
self.player_pos_poz = LONDI
self.SETTING = False
longitude = float(self.player_pos_poz)
latitude = float(self.player_pos_pion)
if self.pressUP == True:
latitude +=0.001
if self.pressDOWN == True:
latitude -=0.001
if self.pressLEFT == True:
longitude -=0.0001
if self.pressRIGHT == True:
longitude +=0.0001
self.localpoz = longitude
self.localpion = latitude
self.PLAYER_POSITION()
def PLAYER_POSITION(self):
my_lat = NumericProperty(self.localpion)
my_lon = NumericProperty(self.localpoz)
playerpos = App.get_running_app().root.ids.player_position
playerpos.lat = NumericProperty(my_lat)
playerpos.lon = NumericProperty(my_lon)
mapposition = App.get_running_app().root.ids.mapview
mapposition.center_on(my_lat,my_lon)
sm = ScreenManager()
sm.add_widget(UsersPlayGameOnMap(name='screenmapmove'))
class gameapp(MDApp):
def build(self):
self.screen = Builder.load_string(screen_helper)
return self.screen
gameapp().run()