1.1.0 • Published 3 years ago

@contentpilot/google-maps v1.1.0

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

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

  1. Sign up for APi key at https://console.cloud.google.com

  2. 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' );

  1. 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,

  1. Bump the version number in package.json
  2. Commit with message pattern of Release x.x.x
  3. Push to master branch to origin