cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Thiza
Frequent Visitor

Powerapps heat map

Good day everyone.

 

I hope you are doing well. I have developed a help desk for capturing the complaints and it records the location of the respondent( a person who attends the complaints) in a form of latitude and longitude. I would like to create a heat map to visualize the hot spot for certain complaints. Please assist me I have tried using bing maps but can only show one location.

 

Your assistance will be highly appreciated 

1 ACCEPTED SOLUTION

Accepted Solutions

@Thiza 

You placed the Set(...) function on the OnSelect property, not in the Items

View solution in original post

5 REPLIES 5
EddieE
Super User
Super User

@Thiza 

You need to create a collection of locations then add that to your map Image property.

 

Note, I think you can only add up to 20 pushpins / locations so if you need more than this you may need to look for another solution eg Power BI

 

However, how I've done this before is:

// set the current gallery item to the Main PushPin
Set(vSiteRecord, ThisItem); 

// Setup map
// Create collection of points to add to the Map
ClearCollect(colPlotPts, 
    AddColumns(myData,
        // Note: PushPin values 28 and 26 are Red and Green colored pushpins (see link)
        "PushPin", If(Lat=vSiteRecord.Lat && Long=vSiteRecord.Long, 28, 26)
    )
);

// Create variable to use in Map Image 
Set(plotPoints2, Concat(colPlotPts, "&pp=" & Text(Lat) & "," & Text(Long) & ";" & PushPin &";" & LabelName));

// LabelName is used to label each PushPin, remove if not needed

- myData has columns with Lats and Longs

 

Push Pin formats/styles can be found here:

https://docs.microsoft.com/en-us/bingmaps/rest-services/common-parameters-and-types/pushpin-syntax-a...

 

Then on my Map I add this code

"https://dev.virtualearth.net/REST/v1/Imagery/Map/"&vMapType&"/"&vSiteRecord.Lat&","&vSiteRecord.Long&"/"&v2Zoom&"?mapSize=500,500" & plotPoints2&"&key=[ ... add your Bing Key here ... ]"

Notes:

- vMapType is a variable for the type of map to display. I only display AerialWithLabels and Road types. I have a button to switch between these, OnSelect

Switch(vMapType,
"AerialWithLabels", Set(vMapType, "Road"),
"Road",Set(vMapType, "AerialWithLabels")
)

 

- v2Zoom is the Zoom of my map. I have a Slider control that changes this ie

EddieE_0-1646294564757.png

 

- map Size, change this to suit your needs

 

As I said above, I don't think the Bing Map can handle more than 20 pushpins so if you need more than that this may not suit?

 

 

 

Thiza
Frequent Visitor

Good day

 

Thank you very much for the response. I am getting an error when I set the variable in the gallery items. Or am I doing it wrong?Capture2.PNG

@Thiza 

You placed the Set(...) function on the OnSelect property, not in the Items

Thiza
Frequent Visitor

I am trying to create a collection on OnStart under apps, I am struggling can you perhaps show me the screen shots

@Thiza 

Select your App --> OnStart, add code similar to

// Your location data
ClearCollect(colPlotPtsALL, yourListName);

Note: the above list needs to contain Lats / Longs and some form of identifier, if needed

 

You then have a Gallery that displays yourListName with any Filters / Sorting that you need. The OnSelect of this Gallery can be set to something like

 

Set(vSiteRecord, ThisItem); 

// Setup map
ClearCollect(colPlotPts, 
    AddColumns(
        Filter(colPlotPtsALL, IsActive_text="TRUE" && !IsBlank(Lat) && BusinessUnit = vSiteRecord.BusinessUnit),
        "PushPin", If(Lat=vSiteRecord.Lat && Long=vSiteRecord.Long, 28, 26)
    )
);

Set(plotPoints2, Concat(colPlotPts, "&pp=" & Text(Lat) & "," & Text(Long) & ";" & PushPin &";" & LabelName));

Navigate(scrSiteDetails, ScreenTransition.Cover)

I use !IsBlank(Lat) to ensure no records with Blank Lats/Longs go into the map collection because this can cause errors.

 

I think this is all you are looking for? Let me know

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events that are happening this month - don't miss out!

Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (2,422)