@contentpilot/google-maps

1.1.0 • Public • Published

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

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i @contentpilot/google-maps

      Weekly Downloads

      0

      Version

      1.1.0

      License

      MIT

      Unpacked Size

      5.03 kB

      Total Files

      7

      Last publish

      Collaborators

      • claytoncollie
      • fh_cp
      • greggc
      • dushakov92