Skip to content

Perform a function when clicking a polygon #697

Answered by giswqs
helsharif asked this question in Q&A
Discussion options

You must be logged in to vote

The Map.on_interaction() method can do that.

def handle_interaction(**kwargs):

https://github.com/opengeos/solara-maxar/blob/0c0e9ecee335eb6b1ec1191b67261a5d6320c216/pages/01_morocco.py#L190

    def handle_click(**kwargs):
        if kwargs.get('type') == 'click':
            latlon = kwargs.get('coordinates')
            geometry = Point(latlon[::-1])
            selected = m.gdf[m.gdf.intersects(geometry)]
            setattr(m, 'zoom_to_layer', False)
            if len(selected) > 0:
                catalog_ids = selected['catalog_id'].values.tolist()

                if len(catalog_ids) > 1:
                    image.o…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by giswqs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants