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 / Google Map static imag...
Power Apps
Unanswered

Google Map static image isn't showing up on main page when selecting sites

(0) ShareShare
ReportReport
Posted on by 10

Hello,

 

I'm extremely new to Power Apps, and I'm creating an app from one of the templates - Site Inspector. For the most part, I've made it my own, however, I'm running into an issue. When a user creates a new record with infomration such as address, company, site, contact, etc. it saves all that information. Hoever, when a user puts in the address for the site of a location, it saves the address, but doesn't save the map to the main menu so they can view it from there. Right now, the user has to go edit the record to view the map. I've gotten it to the point where it is on the main menu, it's just hidden. If you click on the spot of where the map is, it'll move you to the Google Map app, which is perfect. The issue is that the static image won't show up. 😞

 

I can post any code or anything you need to help troubleshoot this, please let me know.

 

Thanks so much!

Categories:
  • Rebetcha Profile Picture
    645 on at
    Can you please add some screen shots? At this point to much variables to have a clue what is causing this.
  • dishwaterdave Profile Picture
    10 on at

    Below is the "Edit Site" page, and the other is the "Main Dashboard" page.

     

    I will post the code that is on the submit button when adding a "New Site".

    If(!IsBlank(NewAddressText.Text)&&!IsBlank(NewCompanyText.Text)&&!IsBlank(NewSiteText.Text)||!IsBlank(NewCompanyText.Text)&&!IsBlank(NewSiteText.Text)&&IsBlank(NewContactText.Text)||IsBlank(NewPhoneText.Text)||IsBlank(NewEmailText.Text)||IsBlank(Map.Image),If(CountRows(CameraPhotos)>=1,UpdateContext({AddPhoto:Patch(SitePhotos,Defaults(SitePhotos),{PhotoId:Max(SitePhotos,PhotoId)+1,Photo:Last(FirstN(CameraPhotos,1)).Photo,ID:Max(SiteInspector,ID)+1,Note:Text(Last(FirstN(CameraPhotos,1)).Note)})}));
    If(CountRows(CameraPhotos)>=2,UpdateContext({AddPhoto:Patch(SitePhotos,Defaults(SitePhotos),{PhotoId:Max(SitePhotos,PhotoId)+1,Photo:Last(FirstN(CameraPhotos,2)).Photo,ID:Max(SiteInspector,ID)+1,Note:Text(Last(FirstN(CameraPhotos,2)).Note)})}));
    If(CountRows(CameraPhotos)>=3,UpdateContext({AddPhoto:Patch(SitePhotos,Defaults(SitePhotos),{PhotoId:Max(SitePhotos,PhotoId)+1,Photo:Last(FirstN(CameraPhotos,3)).Photo,ID:Max(SiteInspector,ID)+1,Note:Text(Last(FirstN(CameraPhotos,3)).Note)})}));
    If(CountRows(CameraPhotos)>=4,UpdateContext({AddPhoto:Patch(SitePhotos,Defaults(SitePhotos),{PhotoId:Max(SitePhotos,PhotoId)+1,Photo:Last(FirstN(CameraPhotos,4)).Photo,ID:Max(SiteInspector,ID)+1,Note:Text(Last(FirstN(CameraPhotos,4)).Note)})}));
    If(CountRows(CameraPhotos)>=5,UpdateContext({AddPhoto:Patch(SitePhotos,Defaults(SitePhotos),{PhotoId:Max(SitePhotos,PhotoId)+1,Photo:Last(FirstN(CameraPhotos,5)).Photo,ID:Max(SiteInspector,ID)+1,Note:Text(Last(FirstN(CameraPhotos,5)).Note)})}));
    If(CountRows(CameraPhotos)>=6,UpdateContext({AddPhoto:Patch(SitePhotos,Defaults(SitePhotos),{PhotoId:Max(SitePhotos,PhotoId)+1,Photo:Last(FirstN(CameraPhotos,6)).Photo,ID:Max(SiteInspector,ID)+1,Note:Text(Last(FirstN(CameraPhotos,6)).Note)})}));
    If(CountRows(CameraPhotos)>=7,UpdateContext({AddPhoto:Patch(SitePhotos,Defaults(SitePhotos),{PhotoId:Max(SitePhotos,PhotoId)+1,Photo:Last(FirstN(CameraPhotos,7)).Photo,ID:Max(SiteInspector,ID)+1,Note:Text(Last(FirstN(CameraPhotos,7)).Note)})}));
    UpdateContext({AddRecord:Patch(SiteInspector,Defaults(SiteInspector),{ID:Max(SiteInspector,ID)+1,Company:NewCompanyText.Text,Site:NewSiteText.Text,PumpSettings:NewPumpSettingsText.Text,Notes:NewNotesText.Text,Address:NewAddressText.Text,Contact:NewContactText.Text,Phone:NewPhoneText.Text,Email:NewEmailText.Text,Map:Map.Image&&If(Radio1_4.Selected.Value="Use GPS for current Location",IsNumeric(Location.Latitude),""),Longitude:If(Radio1_4.Selected.Value="Use GPS for current Location",IsNumeric(Location.Longitude) ,""),IsGPSCoordinates:If(Radio1_4.Selected.Value="Use GPS for current Location","True","False")})});Navigate(DashboardScreen,ScreenTransition.None));If(IsBlank(NewCompanyText.Text)||IsBlank(NewSiteText.Text)||IsBlank(NewAddressText.Text)||IsBlank(ContactEditText.Text)||IsBlank(PhoneEditText.Text)||IsBlank(EmailEditText.Text) ,UpdateContext({Required:true}),UpdateContext({Required:false}))

     

    PowerApp1.PNGPowerApp.PNG

  • Rebetcha Profile Picture
    645 on at
    What did you put in the Image property of the Image control om the view page? I guess you used this article to set up the Google map static image? https://powerapps.microsoft.com/en-us/blog/image-control-static-maps-api/
  • dishwaterdave Profile Picture
    10 on at

    I put the following in the image property:

    "https://maps.googleapis.com/maps/api/staticmap?center=" & EncodeUrl(NewAddressText.Text) & "&size=" & txtImageWidth & "x" & txtImageHeight & "&key="&txtGoogleMapKey.Text
  • Rebetcha Profile Picture
    645 on at
    Where did you put the Google Maps API-Key? You reference txtGoogleMapKey.Text in your formula. Is it in a hidden control on the same screen? Or some place else?
  • dishwaterdave Profile Picture
    10 on at

    I put the Google Maps API-Key on a seperate screen. It's on a seperate page, not on the same screen.

  • dishwaterdave Profile Picture
    10 on at

    Hello,

     

    I hate to bother you, but is there anything else you need from me at this point?

     

    Thanks!

  • Rebetcha Profile Picture
    645 on at

    Sorry, I missed your reply on Monday.

     

    I think I have found your issue. You cannot reference information stored in another screen directly. The value of the text property of your txtGoogleMapKey is cleared from memory the moment you navigate away from that screen. Because the property itself (not it's value) ìs stored in memory throughout the whole app you do not get an error for your formula.

     

    The way to overcome that is to set a variable. A context variable helps by passing data from one screen to  another. A global variable helps by storing the data in a variable that can be used throughout the whole app. 

    In this case I would advise to store the key in a global variable the moment the app is started up. You that by adding the following formula in the OnStart property of the first screen in the app: Set( VariableName, Value ). A logical choice for variable name in this case would be GoogleMapKey. The value part of the formula would be the key. The variable is created under this name the moment you add this formula. After this you can replace txtGooogleMapKey.Text in the image property by the name of the variable. With the name suggested variable name the formula of this property would be:

    "https://maps.googleapis.com/maps/api/staticmap?center=" & EncodeUrl(NewAddressText.Text) & "&size=" & txtImageWidth & "x" & txtImageHeight & "&key="&GoogleMapKey

    You can make the samen change to the Google Map on the other screen and delete the control that you used to store the key. 

     

    Let me know if this works for you.

     

    For more info about variables in PowerApps:

    https://docs.microsoft.com/en-us/powerapps/working-with-variables

    https://docs.microsoft.com/en-us/powerapps/functions/function-set

    https://docs.microsoft.com/en-us/powerapps/functions/function-updatecontext

    https://docs.microsoft.com/en-us/powerapps/functions/function-clear-collect-clearcollect

  • dishwaterdave Profile Picture
    10 on at

    That's okay! 🙂

     

    I tried the suggestion, but when I remove the old variable it's not picking up my API Key, which is stored in the txtGoogleMapKey

     

    I made the variable as you stated on the "Dashboard - Main Screen" for the OnStart Property - Set(GoogleMapKey, key) - However, after I enter that in, I get a caution sign for that property - The types of the specificed context variables are incompatible with the types specified elsewhere

     

    Any ideas?

     

    Thanks!

     

  • Rebetcha Profile Picture
    645 on at
    Sounds like there is already a variable with that name used elsewhere in the app with a different data type. You can acces the apps variables list through the files tab in the app designer: File > Variables. The list contains the variables listed by screen. If you click on a variable you get the definitions, uses and indirect uses of the variable. I would look into that and see if you can find any irregularities.

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 411 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 338

#3
WarrenBelz Profile Picture

WarrenBelz 256 Most Valuable Professional

Last 30 days Overall leaderboard