Pronamic Google Maps Shortcodes

Below, you’ll find a detailed guide on how to add the Pronamic Google Maps Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Pronamic Google Maps Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the Pronamic Google Maps Plugin and the shortcodes it provides:

Plugin Icon
Pronamic Google Maps

"Pronamic Google Maps is a versatile WordPress plugin that allows users to effortlessly integrate and customize Google Maps on their site, enhancing the overall user experience."

★★★★☆ (34) Active Installs: 2000+ Tested with: 4.3.32 PHP Version: false
Included Shortcodes:
  • [googlemaps]
  • [google-maps]
  • [geo]
  • [googlemapsmashup]

Pronamic Google Maps [googlemaps] Shortcode

The Pronamic Google Maps shortcode is a powerful tool for embedding Google Maps into your WordPress site. This shortcode generates a map based on the given attributes, which can include map options, marker clusterer options, and overlapping marker spiderfier options. The ‘echo’ attribute is set to false, ensuring the map is returned as a string rather than directly output. The final result is a fully customizable, interactive Google map.

Shortcode: [googlemaps]

Examples and Usage

Basic example – The shortcode below demonstrates a simple usage of the ‘googlemaps’ shortcode. It doesn’t include any particular attributes, which means it will display a map with default settings.

[googlemaps /]

Advanced examples

Example 1 – The following shortcode includes specific map options. The ‘zoom’ attribute sets the initial zoom level of the map, and the ‘center’ attribute specifies the initial center point of the map.

[googlemaps zoom="10" center="40.7128, -74.0060" /]

Example 2 – This example demonstrates how to use the ‘marker_clusterer’ and ‘overlapping_marker_spiderfier’ options. The ‘marker_clusterer’ attribute groups close markers into clusters, and the ‘overlapping_marker_spiderfier’ attribute manages the display of markers that are in the same location.

[googlemaps marker_clusterer="true" overlapping_marker_spiderfier="true" /]

Example 3 – This shortcode shows how to combine multiple attributes. It includes ‘zoom’, ‘center’, ‘marker_clusterer’, and ‘overlapping_marker_spiderfier’ attributes. This will display a map with specified zoom level and center point, and it will also enable marker clustering and overlapping marker spiderfier.

[googlemaps zoom="10" center="40.7128, -74.0060" marker_clusterer="true" overlapping_marker_spiderfier="true" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [googlemaps] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'googlemaps',       array( __CLASS__, 'shortcode_map' ) );

Shortcode PHP function:

function shortcode_map( $atts ) {
		$atts = self::parse_map_options( $atts );
		$atts = self::parse_marker_clusterer_options( $atts );
		$atts = self::parse_overlapping_marker_spiderfier_options( $atts );

		$atts['echo'] = false;

		return Pronamic_Google_Maps_Maps::render( $atts );
	}

Code file location:

pronamic-google-maps/pronamic-google-maps/classes/Pronamic/Google/Maps/Shortcodes.php

Pronamic Google Maps [google-maps] Shortcode

The Pronamic Google Maps shortcode is a useful tool for embedding Google Maps into WordPress posts. This shortcode calls the function ‘shortcode_map_hyphen’, which returns the ‘shortcode_map’ function with the given attributes ($atts). This implies that the [google-maps] shortcode is a simplified way to call the ‘shortcode_map’ function, making map integration easier.

Shortcode: [google-maps]

Examples and Usage

Basic example – A straightforward usage of the Pronamic Google Maps shortcode. This example will display the Google Map as per the default settings configured in the Pronamic Google Maps plugin.

[google-maps /]

Advanced examples

Displaying a Google Map with specified latitude and longitude. The map will center on the provided coordinates.

[google-maps lat="40.7128" lon="-74.0060" /]

Combining multiple parameters to customize the Google Map display. This example includes latitude, longitude, zoom level, and map type.

[google-maps lat="40.7128" lon="-74.0060" zoom="13" type="satellite" /]

Using the shortcode to display a Google Map with a marker at a specific address. The map will automatically geocode the address and place a marker.

[google-maps address="1600 Amphitheatre Parkway, Mountain View, CA" /]

Please note, the actual shortcode usage might vary based on the configuration options available in your Pronamic Google Maps plugin. Always refer to the plugin’s documentation for the most accurate and up-to-date information.

PHP Function Code

In case you have difficulties debugging what causing issues with [google-maps] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'google-maps',      array( __CLASS__, 'shortcode_map_hyphen' ) );

Shortcode PHP function:

function shortcode_map_hyphen( $atts ) {
		// _deprecated_function('Pronamic Google Maps shortcode [google-maps]', '2.3', 'Pronamic Google Maps shortcode [googlemaps]');

		return self::shortcode_map( $atts );
	}

Code file location:

pronamic-google-maps/pronamic-google-maps/classes/Pronamic/Google/Maps/Shortcodes.php

Pronamic Google Maps [geo] Shortcode

The Pronamic Google Maps shortcode is a handy tool for customizing your WordPress map displays. This shortcode leverages the ‘shortcode_geo’ function to override the ‘echo’ attribute, ensuring map data isn’t prematurely outputted. Instead, it uses the Pronamic_Google_Maps_GeoMicroformat class to render map details, providing more control over your map displays.

Shortcode: [geo]

Examples and Usage

Basic example – Utilizes the ‘geo’ shortcode to render a map without any additional parameters.

[geo /]

Advanced examples

1. Displaying a map with specific latitude and longitude by passing the ‘lat’ and ‘lng’ attributes. In this example, the coordinates for New York City are used.

[geo lat="40.7128" lng="-74.0060" /]

2. Adding a title to the map by passing the ‘title’ attribute. This title will be displayed on the map marker.

[geo lat="40.7128" lng="-74.0060" title="New York City" /]

3. Controlling the zoom level of the map by passing the ‘zoom’ attribute. The value for zoom level ranges from 1 (world view) to 20 (street view).

[geo lat="40.7128" lng="-74.0060" title="New York City" zoom="10" /]

Please note that the ‘geo’ shortcode will not echo any output due to the ‘echo’ attribute being overridden in the function. Instead, it will return the rendered map, which can then be displayed on the website.

PHP Function Code

In case you have difficulties debugging what causing issues with [geo] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'geo',              array( __CLASS__, 'shortcode_geo' ) );

Shortcode PHP function:

function shortcode_geo( $atts ) {
		// Override echo
		$atts['echo'] = false;

		return Pronamic_Google_Maps_GeoMicroformat::render( $atts );
	}

Code file location:

pronamic-google-maps/pronamic-google-maps/classes/Pronamic/Google/Maps/Shortcodes.php

Pronamic Google Maps [googlemapsmashup] Shortcode

The Pronamic Google Maps shortcode enables the display of Google Maps within your WordPress site. It parses map and marker clusterer options, decodes HTML entities, and renders the map.

Shortcode: [googlemapsmashup]

Parameters

Here is a list of all possible googlemapsmashup shortcode parameters and attributes:

  • query – Defines the specific map data to display

Examples and Usage

Basic example – A simple usage of the ‘googlemapsmashup’ shortcode without any additional parameters.

[googlemapsmashup]

Advanced examples

Adding the ‘query’ parameter to the shortcode, which can be used to customize the map’s content. Here, we are querying for all posts with the category ‘travel’.

[googlemapsmashup query="category_name=travel"]

Using the shortcode with multiple parameters. This example includes ‘query’ to specify the category, and ‘zoom’ to adjust the zoom level of the map.

[googlemapsmashup query="category_name=travel" zoom=10]

Using the shortcode with complex query parameters. This example queries for posts in the ‘travel’ category, published in the year 2022, and sorts them by date in descending order.

[googlemapsmashup query="category_name=travel&year=2022&orderby=date&order=DESC"]

PHP Function Code

In case you have difficulties debugging what causing issues with [googlemapsmashup] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'googlemapsmashup', array( __CLASS__, 'shortcode_mashup' ) );

Shortcode PHP function:

function shortcode_mashup( $atts ) {
		$atts = wp_parse_args( $atts, array(
			'query' => array(),
		) );

		$atts = self::parse_map_options( $atts );
		$atts = self::parse_marker_clusterer_options( $atts );

		// Query
		$query = $atts['query'];

		if ( is_string( $query ) ) {
			$query = html_entity_decode( $query );
		}

		unset( $atts['$query'] );

		// Override echo
		$atts['echo'] = false;

		return Pronamic_Google_Maps_Mashup::render( $query, $atts );
	}

Code file location:

pronamic-google-maps/pronamic-google-maps/classes/Pronamic/Google/Maps/Shortcodes.php

Conclusion

Now that you’ve learned how to embed the Pronamic Google Maps Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *