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.

    Examples

    Hide zoomControl on fly.

    add_filter("wpgmp_map_options","wpgmp_map_options",2,4);
    
    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.

    Examples

    Display locations listing left of the map instead of bottom.

    add_filter("wpgmp_map_output","wpgmp_map_output",2,4);
    
    function wpgmp_map_output($output,$map_div,$listing_div,$map_id)
    {
    	$output="
    	
    	<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.

    Examples

    add_filter("wpgmp_center_latitude","wpgmp_center_latitude",1,2);
    
    function wpgmp_center_latitude($latitude,$map_id)
    {
    	return $latitude;	
    }
    

  • wpgmp_center_longitude
  • Description

    Modify center longitude of the map on fly.

    Examples

    add_filter("wpgmp_center_longitude","wpgmp_center_longitude",1,2);
    
    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.

    Examples

    add_filter("wpgmp_listing_html","wpgmp_listing_html",1,4);
    
    function wpgmp_listing_html($output,$variables,$post_id,$map_id)
    {
    	
            $custom_fields=get_post_meta($post_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.

    Examples

    add_filter("wpgmp_markers","add_markers",1,2);
    
    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.

    Examples

    add_filter("wgmp_infowindow_content","wgmp_infowindow_title",1,2);
    
    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.

    Examples

    
    add_filter("wpgmp_categories","wpgmp_category_locations",1,2);
    
    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.

    Examples

    
    add_filter('wpgmp_marker_source','wpgmp_marker_source',1,2);
    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.

    Examples

    
    add_filter('wpgmp_geotags_content','wpgmp_geotags_content',1,3);
    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.