WP Google Map Shortcodes

Below, you’ll find a detailed guide on how to add the Wp Google Map 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 Wp Google Map Plugin shortcodes not to show or not to work correctly.

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

Plugin Icon
=== WordPress Plugin for Google Maps – WP MAPS

"WP MAPS is a WordPress plugin for Google Maps integration. It simplifies embedding custom, interactive maps into your site. Ideal for businesses, bloggers, and event planners."

★★★★✩ (119) Active Installs: 90000+ Tested with: 6.3.2 PHP Version: 5.3
Included Shortcodes:
  • [put_wpgm]
  • [display_map]

WP Google Map [put_wpgm] Shortcode

The WP Google Map Plugin shortcode, ‘put_wpgm’, is designed to display a specific location on a map. This shortcode calls the function ‘wpgmp_show_location_in_map’, which generates a map view based on the attributes provided. If an error occurs, it displays a message with the error details.

Shortcode: [put_wpgm]

Examples and Usage

Basic example – A basic usage of the shortcode to display a specific location on the Google map.

[put_wpgm id=1 /]

Here, ‘id’ is the unique identifier of the location that you want to show on the map. Replace ‘1’ with the actual id of your location.

Advanced examples

Using the shortcode to display a specific location on the Google map with additional attributes like ‘zoom’ and ‘marker’.

[put_wpgm id=1 zoom=10 marker="yes" /]

In this example, ‘zoom’ is used to specify the zoom level of the map, and ‘marker’ is used to decide whether to show the marker on the map or not. Replace ’10’ with your desired zoom level and ‘yes’ with ‘no’ if you don’t want to display the marker.

Using the shortcode to display multiple locations on the Google map.

[put_wpgm id="1,2,3" /]

In this example, you can specify multiple location ids separated by commas. The map will display all the locations with the specified ids.

PHP Function Code

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

Shortcode line:

add_shortcode( 'put_wpgm',                      array( $this, 'wpgmp_show_location_in_map' ) );

Shortcode PHP function:

function wpgmp_show_location_in_map($atts, $content = null) {
			
			try {
				$factoryObject = new WPGMP_Controller();
				$viewObject = $factoryObject->create_object( 'shortcode' );
				$output = $viewObject->display( 'put-wpgmp',$atts );
				 return $output;

			} catch (Exception $e) {
				echo WPGMP_Template::show_message( array( 'error' => $e->getMessage() ) );

			}

		}

Code file location:

wp-google-map-plugin/wp-google-map-plugin/wp-google-map-plugin.php

WP Google Map [display_map] Shortcode

The WP Google Map Plugin shortcode ‘display_map’ is designed to display a map on your WordPress site. It uses a factory object to create a view object, which then displays the map. In case of an error, it catches the exception and displays an error message. This ensures smooth user experience by handling potential issues efficiently.

Shortcode: [display_map]

Examples and Usage

Basic example – A basic usage of the ‘display_map’ shortcode would be to simply call the shortcode without any parameters. This will display the map with default settings.

[display_map /]

Advanced examples

Displaying a map with specific attributes requires adding parameters to the shortcode. The parameters are added inside the shortcode brackets, separated by spaces. Each parameter is written as a key-value pair, with the key and value separated by an equals sign.

For example, if you want to display a map with a specific zoom level and center coordinates, you would use the ‘zoom’ and ‘center’ parameters, respectively. The values for these parameters should be numbers representing the desired zoom level and coordinates.

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

Another example would be to display a map with markers at specific locations. This can be achieved by using the ‘markers’ parameter. The value for this parameter should be a string containing the coordinates for each marker, separated by semicolons.

[display_map markers="40.7128, -74.0060; 34.0522, -118.2437" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'display_map',                   array( $this, 'wpgmp_display_map' ) );

Shortcode PHP function:

function wpgmp_display_map($atts) {

			try {
				$factoryObject = new WPGMP_Controller();
				$viewObject = $factoryObject->create_object( 'shortcode' );
				 $output = $viewObject->display( 'display-map',$atts );
				 return $output;

			} catch (Exception $e) {
				echo WPGMP_Template::show_message( array( 'error' => $e->getMessage() ) );

			}

		}

Code file location:

wp-google-map-plugin/wp-google-map-plugin/wp-google-map-plugin.php

Conclusion

Now that you’ve learned how to embed the Wp Google Map 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 *