Trouble with a plugin

I created an aurelia project with “dotnet new aurelia”.

I’m trying to use the aurelia -google-maps plugin, I followed the directions here to make changes to boot.ts: https://www.npmjs.com/package/aurelia-google-maps

    aurelia.use
        .plugin('aurelia-google-maps', (config: any) => {
            config.options({
                apiKey: false, // use `false` to disable the key
                apiLibraries: 'drawing,geometry', //get optional libraries like drawing, geometry, ... - comma seperated list
                options: { panControl: true, panControlOptions: { position: 9 } }, //add google.maps.MapOptions on construct (https://developers.google.com/maps/documentation/javascript/3.exp/reference#MapOptions)
                language: 'en', // default: uses browser configuration (recommended). Set this parameter to set another language (https://developers.google.com/maps/documentation/javascript/localization)
                region: 'US', // default: it applies a default bias for application behavior towards the United States. (https://developers.google.com/maps/documentation/javascript/localization)
                markerCluster: {
                    enable: false,
                    src: 'https://cdn.rawgit.com/googlemaps/v3-utility-library/99a385c1/markerclusterer/src/markerclusterer.js', // self-hosting this file is highly recommended. (https://developers.google.com/maps/documentation/javascript/marker-clustering)
                    imagePath: 'https://cdn.rawgit.com/googlemaps/v3-utility-library/tree/master/markerclusterer/images/m', // the base URL where the images representing the clusters will be found. The full URL will be: `{imagePath}{[1-5]}`.`{imageExtension}` e.g. `foo/1.png`. Self-hosting these images is highly recommended. (https://developers.google.com/maps/documentation/javascript/marker-clustering)
                    imageExtension: 'png',
                }
            });
        });

I’m getting an error “Unable to find module with ID: aurelia-google-maps”.

What am I missing? Is this a problem with the plugin or am I doing something wrong with aurelia?

Try wrapping it in PLATFORM.moduleName, for example:

aurelia.use.plugin(PLATFORM.moduleName('aurelia-google-maps'), ...)

Yep same like here 0.33.1 - webpack - config.globalResources not working

Cool, that works. Why does that work? What is PLATFORM.moduleName doing?

@mgroves

When you use webpack you should use PLATFORM.moduleName. See the following link

@michaelbull kindly addressed this in the plugin README which has been merged in. I am about to do a release which also has some other pull requests added in as well.

@mgroves The reason why that works is because aurelia-webpack-loader statically analyzes all your project files and looks for the magic string “PLATFORM.moduleName”, then extracts the text content of that call and passes that to webpack to make sure it includes the file in the build.

1 Like