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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / [pcf-1022] [Error] Con...
Power Apps
Unanswered

[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
    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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard