Hooks for Google Maps Plugin

You are here : Home / Hooks for Google Maps Plugin

Hooks are available for this google maps wordpress plugin to give you ability to customize map, add or remove markers on fly or modify html structure of info window etc. Below are the list of supported Filters.

  • wpgmp_map_options
  • Description

    You can modify map options on fly like scrollwheel, panControl, zoomControl etc.


    Hide zoomControl on fly.

    function wpgmp_map_options($options,$map_id)
            if($map_id==9) // here we disabled the zoom control for map id 7. 
            $options["zoomControl"] = false;
    	return $options;	

  • wpgmp_map_output
  • Description

    You can modify container of the map and listing using this filter.


    Display locations listing left of the map instead of bottom.

    function wpgmp_map_output($output,$map_div,$listing_div,$map_id)
    	<table width='100%'><tr><td width='50%'  valign='top' style='vertical-align:top;'>".$listing_div."</td><td width='50%' valign='top' style='vertical-align:top;'>".$map_div."</td></tr></table>";
    	return $ouput;	

  • wpgmp_center_latitude
  • Description

    Modify center latitude of the map on fly.


    function wpgmp_center_latitude($latitude,$map_id)
    	return $latitude;	

  • wpgmp_center_longitude
  • Description

    Modify center longitude of the map on fly.


    function wpgmp_center_longitude($longitude,$map_id)
    	return $longitude;	

  • wpgmp_listing_html
  • Description

    You can display more fields or information into location details on location listing.


    function wpgmp_listing_html($output,$variables,$post_id,$map_id)
    	$output =$output." Nearest Spot".$custom_fields["nearest_spot"];
    	return $output;	

  • wpgmp_markers
  • Description

    Add or remove markers from the map on fly. Very useful if you want to display markers on map using external source.


    function add_markers($markers,$map_id)
    	return $markers;	

  • wgmp_infowindow_content
  • Description

    Modify info window contents or add custom html in the info window contents.


    function wgmp_infowindow_title($title,$map_id)
    	$title ="<p style='color:red;font-size:20px;'>$title</p>";
    	return $title;	

  • wpgmp_categories
  • Description

    You can add or modify the categories with help of this filter.


    function wpgmp_category_locations($locations,$map_id)
    	return $locations;	

  • wpgmp_marker_source
  • Description

    You can add markers from external database or source to google maps using this filter. You just need to create an array of markers using your external database or any other sources. Marker array should have following properties.

    • id – Each location should have a unique ID.
    • address – address of the location.
    • latitude – latitude of the location.
    • longitude – longitude of the location.
    • title – Title of the location.
    • message– Infowindow message to be displayed on marker click.
    • icon – Path of the icon file. (Optional)
    • category – Category of the marker. it should exactly match with categories you created using category manager.


    function wpgmp_marker_source($markers,$map_id) {
    	$new_markers[] = array(
    	    'id' => 'Location unique ID here',
                'address' => 'Location Address here',
                'latitude' => 51.520738,
                'longitude' => -0.127691,
                'title' => 'Location Title here',
                'message' => 'Infowindow Message here',
                'icon' => 'Path of markers Icon here',
                'category' => 'Your Category Title here');
    	 return $new_markers;

  • wpgmp_geotags_content
  • Description

    You can display featured image or custom fields related to the post using this filter.


    function wpgmp_geotags_content($content,$post_id,$map_id) {
    	$content = ""; //reset the $content
             //retrieve post title
             $content = "Post Title : ".get_the_title($post_id);
            //retrieve featured image of the post
             if (has_post_thumbnail( $post_id ) ) {
             $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), 'single-post-thumbnail' ); 
             $content .= "<br>Featured Image : <img width='100' height='100' src='".$image[0]."' />";
             //retrieve the_excerpt of the post
             $content.="<br>Post Excerpt : ".get_the_excerpt($post_id);
             //retrieve custom fields value of the post. 
             $content .="<br>Custom Field : ".get_post_meta($post_id, "show_facebook", true);
             //return your modified infowindow message. 
             return $content;

Customize Product according to your requirements?

We will be glad to discuss any of your needs related to our wordpress plugins . if any of functionality you'd like to see in products, you can reach us by via email hello@flippercode.com.