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 / [pcf-1022] [Error] Con...
Power Apps
Answered

[pcf-1022] [Error] Control source code declares an internal module or namespace

(0) ShareShare
ReportReport
Posted on by 11

I'm creating a dataset control which will load a map via the Google Maps Javascript API and display data from each of the records in the dataset.

 

The issue I have is that, as far as I can tell, the Google Maps Javascript API library must be loaded from Google's servers at runtime by inserting a script element into the DOM as part of the control's init() method. The script element has the onload property set to execute a callback function (initMap) which creates a new instance of the google.maps.Map object and displays the map.

 

This is all fine except that I need the new google.maps.Map object to persist outside of initMap() so I can access it later from the updateView() method to manipulate the map. I've tried to achieve this by extending the Window interface to allow the creation of a global variable while maintaining strong typing, however the PCF validation script then throws an error on build.

 

Here's an example:

declare global {
    interface Window { myMapgoogle.maps.Map }
}

[pcf-1022] [Error] Control source code declares an internal module or namespace.

 

I realise I could work around the error by doing something like this:
(<any>window).myMap = new google.maps.Map(...);
but that destroys any further type checking on the map object which is what I want to avoid.
 
Is there another way to create a global variable on the window object without the PCF validation script complaining? If not, is there another way to persist the map object between initMap and updateView?
I have the same question (0)
  • Verified answer
    Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at

    I'm not an expert, but maybe there is another way to approach this using an npm Package (something like this https://www.npmjs.com/package/google-maps ) ?

  • Verified answer
    paul365 Profile Picture
    11 on at

    Thanks, I must have missed that package while looking through the npm repository. It looks like it should work but I ended up finding another solution in the meantime that might be useful for someone who has a similar issue.

     

    As an example, I created an ambient declaration file (interfaces.d.ts) and put the following inside it:

     

    declare interface Window {
        myMapgoogle.maps.Map
    }
     
    This allowed me to use window.myMap while retaining strong typing and keeping both the typescript compiler and PCF validation script happy.
  • Rei0116 Profile Picture
    Microsoft Employee on at

    Hi

    You can check here https://www.npmjs.com/package/google-maps 

  • BenClough Profile Picture
    2 on at

    God bless you for going back and writing your solution 😂

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
WarrenBelz Profile Picture

WarrenBelz 400 Most Valuable Professional

#2
11manish Profile Picture

11manish 141 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 109 Super User 2026 Season 2

Last 30 days Overall leaderboard