A Google Maps library for WordPress.

0.2.7 2020-05-28 15:03 UTC


Scrutinizer Code Quality Code Coverage Build Status DeepScan Grade

A Google Maps library for WordPress.


This project can be installed via Composer:

composer require clubdeuce\wp-google-maps

Simply include autoload.php from your vendor directory and the library will be included.


A simple example:

use Clubdeuce\WPGoogleMaps\Google_Maps;
use Clubdeuce\WPGoogleMaps\Map;
use Clubdeuce\WPGoogleMaps\Marker;
use Clubdeuce\WPGoogleMaps\Map_View;


// Register the conditions under which to load the necessary javascript
// You can use WP specific ( e.g. is_single, is_search, etc ) or any 
// valid callback function or closure.
Google_Maps::register_script_condition( 'is_single' );

//Create a new map object
$map = Google_Maps::make_new_map();

//Create a new marker object
$marker = Google_Maps::make_marker_by_address( '1600 Pennsylvania Ave NW Washington DC' );

//Set the info window content
$marker->info_window()->set_content( 'The White House' );

//Add the marker to the map
$map->add_marker( $marker );

//Render the map