Interactive Geo Maps Shortcodes

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

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

Plugin Icon
Interactive Geo Maps

"Interactive Geo Maps is a powerful WordPress plugin that allows you to create and display customizable, interactive maps on your website. Ideal for visual storytelling or geographical data representation."

★★★★☆ (47) Active Installs: 30000+ Tested with: 6.4 PHP Version: 7.0
Included Shortcodes:
  • [display-map]
  • [map-title-current]
  • [map-dropdown]
  • [map-list]

Interactive Geo Maps [display-map] Shortcode

The Interactive Geo Maps plugin shortcode, ‘display-map’, is used to render maps on your website. This shortcode takes in attributes like ‘id’, ‘meta’, ‘regions’, ’roundmarkers’, and ‘demo’. It checks if the ‘id’ attribute is set, and if it is of the post type ‘igmap’. If these conditions are met, it creates a new map and renders it on the page. Additionally, it adds footer scripts.

Shortcode: [display-map]

Parameters

Here is a list of all possible display-map shortcode parameters and attributes:

  • id – Specific map’s unique identifier
  • meta – Additional data related to the map
  • regions – Specific areas to be highlighted on the map
  • roundmarkers – Enables the use of round markers on the map
  • demo – Activates demonstration mode for the map

Examples and Usage

Basic example – A simple way to display a map using the shortcode. The ‘id’ attribute is used to specify the map to be displayed.

[display-map id=1 /]

Advanced examples

Display a map with specific regions highlighted. The ‘regions’ attribute is used to specify the regions to be highlighted.

[display-map id=1 regions="US,CA,MX" /]

Display a map with round markers. The ’roundmarkers’ attribute is used to enable round markers on the map.

[display-map id=1 roundmarkers="true" /]

Display a map with custom meta data. The ‘meta’ attribute is used to specify the custom meta data for the map.

[display-map id=1 meta="custom_data" /]

Display a demo map. The ‘demo’ attribute is used to enable the demo mode for the map.

[display-map id=1 demo="true" /]

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, 'render_shortcode' ) );

Shortcode PHP function:

function render_shortcode( $atts, $content = null, $tag = '' )
    {
        // normalize attribute keys, lowercase
        $atts = array_change_key_case( (array) $atts, CASE_LOWER );
        // override default attributes with user attributes
        $map_atts = shortcode_atts( array(
            'id'           => null,
            'meta'         => null,
            'regions'      => null,
            'roundmarkers' => null,
            'demo'         => null,
        ), $atts, $tag );
        if ( !isset( $map_atts['id'] ) ) {
            return;
        }
        $map_atts['id'] = (int) $map_atts['id'];
        if ( $map_atts['id'] === 0 ) {
            return;
        }
        $id_post_type = get_post_type( $map_atts['id'] );
        if ( $id_post_type !== 'igmap' ) {
            return;
        }
        $map = new Plugin\Map( $this );
        $html = $map->render( $map_atts, $this );
        // add footer scripts
        add_action( 'wp_footer', array( $this, 'footer_content' ) );
        return $html;
    }

Code file location:

interactive-geo-maps/interactive-geo-maps/src/Core.php

Interactive Geo Maps [map-title-current] Shortcode

The Interactive-Geo-Maps plugin shortcode ‘map-title-current’ dynamically generates a title for your map. It retrieves the current map’s title, and if none exists, it defaults to ‘World Map Preview’.

Shortcode: [map-title-current]

Examples and Usage

Basic Example – Map shortcode without any parameters

[map-title-current /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'map-title-current', array( $this, 'render_map_current_title' ) );

Shortcode PHP function:

function render_map_current_title( $atts ) {

		$title = $this->get_current();

		if ( $title !== '' ) {
			/* translators: %s is the name of the current map displaying */
			$html = sprintf( __( '%s Map Preview', 'interactive-geo-maps' ), $title );
		} else {
			$html = __( 'World Map Preview', 'interactive-geo-maps' );
		}

		return sprintf( '<h2>%s</h2>', $html );

	}

Code file location:

interactive-geo-maps/interactive-geo-maps/src/Plugin/Utils/MapListCurrent.php

Interactive Geo Maps [map-dropdown] Shortcode

The Interactive Geo Maps plugin shortcode ‘map-dropdown’ is designed to render a dropdown list of maps. Essentially, it retrieves the list of maps available in the plugin, converts it into a JSON format, and then builds a dropdown menu with these options. The HTML of this dropdown is then returned, ready for display on the webpage.

Shortcode: [map-dropdown]

Examples and Usage

Basic example – A simple usage of the ‘map-dropdown’ shortcode without any additional parameters. This will render a dropdown list of all available maps.

[map-dropdown /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'map-dropdown', array( $this, 'render_map_dropdown' ) );

Shortcode PHP function:

function render_map_dropdown( $atts ) {

		$map_list = new MapList();
		$options  = json_decode( $map_list->maps, true );

		$html = $this->build_select( $options );

		return $html;

	}

Code file location:

interactive-geo-maps/interactive-geo-maps/src/Plugin/Utils/MapListDropdown.php

Interactive Geo Maps [map-list] Shortcode

The Interactive-Geo-Maps plugin shortcode ‘map-list’ generates a list of maps. It uses the ‘render_map_list’ function to create an HTML list of maps. The list is built using the ‘build_list’ method on the map options. If a ‘group’ attribute is provided, it filters the list to show only maps from this group.

Shortcode: [map-list]

Parameters

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

  • group – Specifies the group of maps to be displayed.

Examples and Usage

Basic example – A simple usage of the ‘map-list’ shortcode without any parameters. This will render the list of all maps available in the plugin.

[map-list /]

Advanced examples

Use the ‘map-list’ shortcode with the ‘group’ parameter. This will render the list of maps that belong to the specified group. Here, ‘group’ is the identifier of the group of maps you want to display. If the group does not exist or does not contain any maps, no list will be rendered.

[map-list group="europe" /]

Another example of advanced usage is to use the ‘map-list’ shortcode with multiple ‘group’ parameters. This will render a list of maps that belong to all the specified groups. If any of the groups do not exist or do not contain any maps, those groups will be ignored and the list will contain maps from the remaining groups. In the following example, the shortcode will render a list of maps that belong to either the ‘europe’ group or the ‘asia’ group.

[map-list group="europe,asia" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'map-list', array( $this, 'render_map_list' ) );

Shortcode PHP function:

function render_map_list( $atts ) {

		$map_list = new MapList();
		$options  = json_decode( $map_list->maps, true );

		if( isset( $atts['group'] ) && isset( $options[ $atts['group'] ] ) ){
			$options = [ $atts['group'] => $options[ $atts['group'] ] ];
		}

		$html = $this->build_list( $options );

		return $html;

	}

Code file location:

interactive-geo-maps/interactive-geo-maps/src/Plugin/Utils/MapListOutput.php

Conclusion

Now that you’ve learned how to embed the Interactive Geo 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 *