@contentpilot/google-maps
v1.1.0
Published
JS used to display interactive Google Map with authenticated API key.
Downloads
25
Readme
Content Pilot Google Maps
JS used to display interactive Gogle Map with authenticated API key.
Install as devDependency
npm install @contentpilot/google-maps --save-dev
Require JS file in task runner
./node_modules/@contentpilot/google-maps/index.js
Bind to content area
$('.google-maps').cpGoogleMaps();
Authentication
Sign up for APi key at https://console.cloud.google.com
Add constants to functions.php
define( 'CHILD_THEME_GOOGLE_MAPS', 'API_KEY' );
define( 'CHILD_THEME_TEXTDOMAIN', 'theme-prefix' );
define( 'CHILD_THEME_VERSION', '1.0.0' );
- Enqueue URL with API key
add_action( 'wp_enqueue_scripts', 'theme_prefix_enqueue_google_maps_api' );
/**
* Enqueue Google Maps API with key, only load after global JS
*
* @since 1.0.0
*/
function theme_prefix_enqueue_google_maps_api() {
wp_enqueue_script(
CHILD_THEME_TEXTDOMAIN . '-google-maps',
'//maps.google.com/maps/api/js?key=' . CHILD_THEME_GOOGLE_MAPS,
array( 'global' ),
CHILD_THEME_VERSION,
true
);
}
Publish to NPM
To update this repository on NPM using the GitHub action,
- Bump the version number in
package.json
- Commit with message pattern of
Release x.x.x
- Push to
master
branch toorigin