web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Show/hide label of pin...
Power Apps
Answered

Show/hide label of pins in canvas app map control

(1) ShareShare
ReportReport
Posted on by 188

Hello,

I have a canvas app with map component and i take the list of pins from a sharepoint list.

is there a way to add a button to show or hide the labels of the pins?

 

Thank you,

Giovanni

Categories:
  • Verified answer
    anandm08 Profile Picture
    1,936 Super User 2024 Season 2 on at

    hi @Gprior ,

    Yes, you can add a button to show or hide the labels of the pins on the map in your canvas app.

    Create a variable to manage the visibility of the pin labels. For instance, you can create a boolean variable named showLabels.

     

    // In the OnSelect property of your button, toggle the value of showLabels:
    UpdateContext({showLabels: !showLabels})

     

    Assuming you have a map component named Map1 and the pins are retrieved from a SharePoint list, you can update the labels' visibility based on the showLabels variable.

     

    // In the Items property of your map component, you can use a formula that conditionally includes the labels:
    ForAll(
     YourSharePointList,
     {
     Latitude: ThisRecord.Latitude,
     Longitude: ThisRecord.Longitude,
     Label: If(showLabels, ThisRecord.Label, "")
     }
    )

     

    Replace YourSharePointList with the actual name of your SharePoint list and Latitude, Longitude, and Label with the actual column names used in your list.

  • Gprior Profile Picture
    188 on at

    First of all, thank you @anandm08 for your feedback!

    Most of it worked, unfortunately i'm not able to make the switch work!

    I've update the code like this:

     

    ForAll(
    	Filter(
    		'Elenco Clienti'; TextInput1.Text in 'Ragione Sociale' &&
    		(IsBlank(ComboBox2.Selected.Value) || ComboBox2.Selected.Value = Tipologia.Value) &&
    		(IsBlank(ComboBox3.Selected.Value) || ComboBox3.Selected.Value in Materiale.Value)
    	);
     {
     Latitude: ThisRecord.Latitudine;
     Longitude: ThisRecord.Longitudine;
     Label: If(Nome="true"; ""; ThisRecord.'Ragione Sociale')
     }
    )

     

    I've set the code onstart of the app:

     

    Set(Nome;true)

     

    And i've set my button in onSelect:

     

    UpdateContext({Nome: !Nome})

     

    but still no luck, i'm not able to make the label appear or disappear based on the press of the button! What can be the problem?

     

    Thank you again for the help so far!

    Giovanni

     

     

  • Gprior Profile Picture
    188 on at

    Thank you @anandm08 

    I solved changing the name of the variable (!!) from "nome" to "etichetta" and everything woked like a charm! Thank you again!!

  • Gprior Profile Picture
    188 on at

    I have another question now: is it possible to avoid the map to re-center to the default position every time that i hide or show the labels?

    e.g.: i'm zooming and focusing on some pins, then i press "show/hide labels": labels correctly show (or hide), but the maps is re-centered to the default position - if default position is disabled, the app zooms out until it shows all the pins on the map!

    Do you think it's possible to disable this behaviour?

     

    Thank you!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 345 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 225

#3
M Bilal Khan Profile Picture

M Bilal Khan 192

Last 30 days Overall leaderboard