Below, you’ll find a detailed guide on how to add the Easy Google Maps Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Easy Google Maps Plugin shortcode not to show or not to work correctly.
Before starting, here is an overview of the Easy Google Maps Plugin and the shortcodes it provides:
Easy Google Maps [GMP_SHORTCODE] Shortcode
The Google Maps Easy plugin shortcode, GMP_SHORTCODE, is used to draw maps from a specified shortcode. This function checks if a map ID is provided in the shortcode parameters. If it’s missing or invalid, it returns an error message. If valid, it proceeds to draw the map.
Shortcode: [GMP_SHORTCODE]
Parameters
Here is a list of all possible GMP_SHORTCODE shortcode parameters and attributes:
id
– The unique identifier for the specific map
Examples and Usage
Basic example – Display a map using its unique ID
[GMP_SHORTCODE id=1 /]
Advanced examples
Display a map by referencing both ID and additional parameters. The map will first try to load by ID, but if not found, it will try to load by other parameters.
[GMP_SHORTCODE id=1 param1=value1 param2=value2 /]
Display a map by referencing only additional parameters. The map will try to load by these parameters.
[GMP_SHORTCODE param1=value1 param2=value2 /]
Please note that ‘param1’ and ‘param2’ are placeholders for actual parameter names you would use, and ‘value1’ and ‘value2’ are placeholders for the values those parameters would take. Replace these placeholders with the actual parameter names and values you intend to use.
PHP Function Code
In case you have difficulties debugging what causing issues with [GMP_SHORTCODE]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode(GMP_SHORTCODE, array($this, 'drawMapFromShortcode'));
Shortcode PHP function:
function drawMapFromShortcode($params = null) {
frameGmp::_()->getModule('templates')->loadCoreJs();
if(!isset($params['id']) || empty($params['id'])) {
return __('Empty or Invalid Map ID', GMP_LANG_CODE) . '. ' . __('Please, check your Map Shortcode.', GMP_LANG_CODE);
}
return $this->getView()->drawMap($params);
}
Code file location:
google-maps-easy/google-maps-easy/modules/gmap/mod.php
Conclusion
Now that you’ve learned how to embed the Easy Google Maps Plugin shortcode, 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.
Leave a Reply