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:
[pcf-1022] [Error] Control source code declares an internal module or namespace.
God bless you for going back and writing your solution 😂
Hi
You can check here https://www.npmjs.com/package/google-maps
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:
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 ) ?
WarrenBelz
85
Most Valuable Professional
Michael E. Gernaey
65
Super User 2025 Season 1
mmbr1606
55
Super User 2025 Season 1