Google Maps | Business Directory https://businessdirectoryplugin.com Create any kind of directory on your site, easily Mon, 20 Mar 2023 16:26:27 +0000 en-US hourly 1 https://businessdirectoryplugin.com/wp-content/uploads/2020/10/cropped-Favicon3-32x32.png Google Maps | Business Directory https://businessdirectoryplugin.com 32 32 wpbdp_map_id https://businessdirectoryplugin.com/knowledge-base/wpbdp_map_id/?utm_source=rss&utm_medium=rss&utm_campaign=wpbdp_map_id Wed, 10 Feb 2021 07:00:00 +0000 https://businessdirectoryplugin.com/knowledge-base/wpbdp_map_id/ The Google Maps API offers the option to create maps and styles. When a map with a style is created there, you can use the ID to apply the style to the maps on your site.

The post wpbdp_map_id first appeared on Business Directory.]]>
Heads up!
This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.

The Google Maps API offers the option to create maps and styles. When a map with a style is created there, you can use the ID to apply the style to the maps on your site.

Usage

add_filter( 'wpbdp_map_id', 'set_bd_map_id' );

Parameters

  • $id (string|int) Default is blank

Examples

There are currently no examples for this hook.

Change Log

Added in version 5.2

The post wpbdp_map_id first appeared on Business Directory.]]>
wpbdp_show_google_maps https://businessdirectoryplugin.com/knowledge-base/wpbdp_show_google_maps/?utm_source=rss&utm_medium=rss&utm_campaign=wpbdp_show_google_maps Wed, 10 Feb 2021 07:00:00 +0000 https://businessdirectoryplugin.com/knowledge-base/wpbdp_show_google_maps/ By default, the map is shown. Use this hook to hide the map on some listings.

The post wpbdp_show_google_maps first appeared on Business Directory.]]>
Heads up!
This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.

By default, the map is shown. Use this hook to hide the map on some listings.

Usage

add_filter( 'wpbdp_show_google_maps', 'maybe_hide_bd_map', 10, 2 );

Parameters

  • $show (boolean) Default is true, or the value of the latitude/longitude option.
  • $listing_id (int) The id of the listing

Examples

There are currently no examples for this hook.
The post wpbdp_show_google_maps first appeared on Business Directory.]]>
wpbdp_googlemaps_map_locations https://businessdirectoryplugin.com/knowledge-base/wpbdp_googlemaps_map_locations/?utm_source=rss&utm_medium=rss&utm_campaign=wpbdp_googlemaps_map_locations Wed, 10 Feb 2021 07:00:00 +0000 https://businessdirectoryplugin.com/knowledge-base/wpbdp_googlemaps_map_locations/ Change any locations that have been prepared to show on the map. This hook runs right before the PHP is sent to the javascript that creates the map.

The post wpbdp_googlemaps_map_locations first appeared on Business Directory.]]>
Heads up!
This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.

Change any locations that have been prepared to show on the map. This hook runs right before the PHP is sent to the javascript that creates the map.

Usage

add_filter( 'wpbdp_googlemaps_map_locations', 'change_map_locations', 10, 2 );

Parameters

  • $locations (array) An array of addresses.
    • $locations['address'] (string)
    • $locations['geolocation'] (array) The latitude and longitude.
    • $locations['content'] (string) The content shown in the tooltip.
  • $args (array) All the settings that will be used to create the map

Examples

Change the image for the map pin

This example will replace the pin icon for the map location

add_filter( 'wpbdp_googlemaps_map_locations', 'my_custom_function' );
function my_custom_function( $locations ) {
	foreach ( $locations as $k => $l ) {
		$locations[ $k ]['icon'] = 'https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png'; //change this url with the path of the image you want to place
	}
	
	return $locations;
}

Change the longitude and latitude

this example will change the longitude and latitude on the map for a specific address

add_filter( 'wpbdp_googlemaps_map_locations', 'my_custom_function' );
function my_custom_function( $locations ) {
	foreach ( $locations as $k => $l ) {
		if ( $l['address'] === 'Alaska USA' ) { // replace Alaska USA with the address you want to change
			$locations[ $k ]['geolocation']->lat = '42.8400295'; // replace the latitude with the one you want to show on the map
			$locations[ $k ]['geolocation']->lng = '-85.5130942'; // replace the longitude with the one you want to show on the map
		}
	}
	
	return $locations;
}
The post wpbdp_googlemaps_map_locations first appeared on Business Directory.]]>
wpbdp_googlemaps_map_args https://businessdirectoryplugin.com/knowledge-base/wpbdp_googlemaps_map_args/?utm_source=rss&utm_medium=rss&utm_campaign=wpbdp_googlemaps_map_args Wed, 10 Feb 2021 07:00:00 +0000 https://businessdirectoryplugin.com/knowledge-base/wpbdp_googlemaps_map_args/ This hook allows you to customize pretty much anything about the way the map is displayed: size, styling, map type, and more.

In this example from the Google Map docs, mapOptions is the value that this hook can customize.

var mapOptions = {
  zoom: 8,
  center: myLatlng,
  mapTypeId: 'satellite'
};
var map = new google.maps.Map(document.getElementById('map'), mapOptions);
The post wpbdp_googlemaps_map_args first appeared on Business Directory.]]>
Heads up!
This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.

This hook allows you to customize pretty much anything about the way the map is displayed: size, styling, map type, and more.

In this example from the Google Map docs, mapOptions is the value that this hook can customize.

var mapOptions = {
  zoom: 8,
  center: myLatlng,
  mapTypeId: 'satellite'
};
var map = new google.maps.Map(document.getElementById('map'), mapOptions);

Usage

add_filter( 'wpbdp_googlemaps_map_args', 'customize_bd_map', 10, 2 );

Parameters

  • $settings (array) All the settings used to generate the map.
  • $locations (array) The locations that will be displayed on the map.

Examples

There are currently no examples for this hook.
The post wpbdp_googlemaps_map_args first appeared on Business Directory.]]>
wpbdp_map_markers https://businessdirectoryplugin.com/knowledge-base/wpbdp_map_markers/?utm_source=rss&utm_medium=rss&utm_campaign=wpbdp_map_markers Wed, 10 Feb 2021 07:00:00 +0000 https://businessdirectoryplugin.com/?post_type=ht_kb&p=1312484 This hook allows you to replace the numbered cluster icons with your own in the Google Maps plugin. The default path is "plugins/business-directory-googlemaps/resources/marker-clusterer/markers/m". This points to multiple files in that folder: m1.png, m2.png, m3.png, m4.png, and m5.png.

When this hook is used, you must have images for each of the 5 levels. These images do not include any numbers. The numbers are added automatically by Google Maps.

The post wpbdp_map_markers first appeared on Business Directory.]]>
Heads up!
This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.

This hook allows you to replace the numbered cluster icons with your own in the Google Maps plugin. The default path is “plugins/business-directory-googlemaps/resources/marker-clusterer/markers/m”. This points to multiple files in that folder: m1.png, m2.png, m3.png, m4.png, and m5.png.

When this hook is used, you must have images for each of the 5 levels. These images do not include any numbers. The numbers are added automatically by Google Maps.

Usage

add_filter( 'wpbdp_map_markers', 'change_cluster_icons' );

Parameters

  • $path (string) The path to the images, including the prefix on the images.

Examples

There are currently no examples for this hook.

Change Log

Added in version 5.2

The post wpbdp_map_markers first appeared on Business Directory.]]>
wpbdp_address_format https://businessdirectoryplugin.com/knowledge-base/wpbdp_address_format/?utm_source=rss&utm_medium=rss&utm_campaign=wpbdp_address_format Wed, 10 Feb 2021 07:00:00 +0000 https://businessdirectoryplugin.com/knowledge-base/wpbdp_address_format/ Customize the format of the address used for Google Maps. The easiest way to customize this is in the Tooltip content option in the settings. Use this hook if you need extra customization, or would like different listings to use different formats.

The post wpbdp_address_format first appeared on Business Directory.]]>
Heads up!
This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.

Customize the format of the address used for Google Maps. The easiest way to customize this is in the Tooltip content option in the settings. Use this hook if you need extra customization, or would like different listings to use different formats.

Usage

add_filter( 'wpbdp_address_format', 'change_bd_map_address_format', 10, 2 );

Parameters

  • $address_format (string) Default is ‘[address], [city], [state] [zip] [country]'
  • $atts (array)
    • $atts['listing_id'] (int) The ID of the listing to display.
    • $atts['pretty'] (bool) This is true when the address is displayed, and false when used to locate the address on the map.

Examples

There are currently no examples for this hook.

Change Log

Added in version 5.2

The post wpbdp_address_format first appeared on Business Directory.]]>