Get Geolocation with navigator.geolocation.getCurrentPosition

Hi!

I would like to get the geolocation of the user which should be possible by using the javascript function navigator.geolocation.getCurrentPosition(). I’m not that familiar with how all of that works, but I tried it like this (which is of course integrated into another part of the app):

class LocationState(rx.State):
    geolocation: dict

    def update_geolocation(self, geolocation):
        self.geolocation = geolocation
        print(geolocation)

    @rx.event
    def get_client_values(self):
        return [
            rx.call_script(
                "navigator.geolocation.getCurrentPosition",
                callback=LocationState.update_geolocation,
            ),
        ]


def location_state_demo():
    return rx.vstack(
        rx.button(
            "Update Values",
            on_click=LocationState.get_client_values,
        ),
        rx.text(f"Location: {LocationState.geolocation}"),
    )

However, I am getting the error:

[Reflex Backend Exception]
 Traceback (most recent call last):
  File "C:\Users\[...]\.venv\Lib\site-packages\reflex\state.py", line 1766, in _process_event
    events = fn(**payload)
TypeError: LocationState.update_geolocation() missing 1 required positional argument: 'geolocation'

I am propably doing something completely wrong, but can’t find any resources on this anywhere - so I’d be really glad if someone could show me the way :slight_smile: