Single Location - Shortcode

Using the Single Location shortcode you can display the location details of a particular item. Item can be a post, BuddyPress member and others that might be provided by premium extensions. You can use the shortcode to display the location information within the content of your pages, posts, and template files. You can display elements like Google map, title, directions link, live directions and more.

Shortcode Usage

[gmw_single_location]

Shortcode Attributes

object

The object which you would like to display its location. An object can be "post", to display the location of a post ( when using the  Posts Locator core extension ), "member", to display the location of a BuddyPress member ( when using Members Locator add-on ), and other objects which might be provided by different extensions.

Default value: post.

Example:

[gmw_single_location object="post"]

element_id

The element ID is a unique ID you can apply to the Single location shortcode. The element ID is useful when you want to apply custom styling to a specific Single Location shortcode or make use of the hooks provided by the shortcode. The element ID will help you distinguish between the different Single Location shortcodes. 

Usage: Use any characters as you wish. Otherwise, the plugin will create a random numeric value for you made up of 3 digits. Make sure you do not use the same element ID with more than one shortcode. As well make sure that the element ID that you choose is not being used by GEO my WP forms or the Current Location widget/shortcode. 

Default value: a random numeric value.

Example: 

[gmw_single_location object="post" element_id="25"]

object_id

The object ID is the ID of the item that you would like to display. For example, the item ID of a post will be the post ID. Same goes for a member ID and for the other objects. 

Usage: to display the location of a specific item uses its item ID with the object_id attribute. Otherwise, set it to 0 ( object_id="0") if you want the item to be displayed automatically based on the single item page. For example, if the object ID of a post set to 0, then the shortcode will display its content on a single post page. In this case, it is the location of the post that is being displayed ( when the post has a location ). 

Default value: 0.

Example: 

[gmw_single_location object="post" element_id="25" object_id="10"]

elements

Use this to enable the elements that you would like to display. You can choose single or multiple elements. You can also set the order that you would like to display the elements. 

The elements available are: 

  • title - the title of the item. The title of the post will be the post title, the title of a member will be its displayed name and same for other elements. 
  • address - the address fields of the location. map 
  • Map - Google map showing the location of the item. 
  • distance - The distance between the location to the user's current location ( if exists ). 
  • directions_link - direction link that will open a new page with Google map showing the directions from the location to the user's current location, if exists. 
  • live_directions - display directions system within the shortcode content. 
  • directions_panel - The holder that will display the directions results ( must have live_directions element set ). 

Usage: enter the elements that you would like to display and in the order that you would like to display them, comma-separated.

Example: 

[gmw_single_location object="post" elements="title,distance,map,address,directions_link"]

address_fields 

Enter the address fields that you would like to display. You can choose a single or multiple address fields. The fields available are street, premise, city, region_name ( state ), postcode, county_name, and address ( for full address ). 

Usage: Enter any of the address fields that you would like to display comma separated. 

Default value: address.

Example: 

[gmw_single_location object="post" address_fields="city,postcode,region_name"]

location_meta

The location meta fields that you would like to display ( this attribute only available with the 'post' object at the moment).

Usage: Enter the additional fields that you would like to display, comma-separated. The default fields available are phone, fax, email, website.

Example: 

[gmw_single_location object="post" location_meta="phone,email,website"]

units  

the distance units you would like to use when calculating the distance between the displayed location and the visitor's current location, when available. 

Usage: set the units to attribute to "m" form miles or "k" for kilometres.

Default value: "k".

Example: 

[gmw_single_location object="post" units="m"]

map_height

The map height.

Usage: set the map's height in pixels or percentage ( ex. 250px or 100% ).

Default value: 250px.

Example: 

[gmw_single_location object="post" map_height="300px"]

map_width

The map width.

Usage: set the map's height in pixels or percentage ( ex. 250px or 100% ).

Default value: 250px.

Example: 

[gmw_single_location object="post" map_height="300px" map_width="100%"]

map_type

Set the map type. 

Usage: enter the map type that you would like to use. The available map types are ROADMAP, SATELLITE, HYBRID, and TERRAIN.

Default value: ROADMAP.

Example: 

[gmw_single_location object="post" map_type="ROADMAP"]

zoom_level

The zoom level defines the resolution of the current view. Zoom levels between 0 ( the lowest zoom level, in which the entire world can be seen on one map ) and 18 ( down to streets and individual buildings ) are possible. 

Usage: enter a numeric value between 1 to 18 that will be used as the zoom level. 

Default value: 13.

Example: 

[gmw_single_location object="post" zoom_level="12"]

scrollwheel_map_zoom 

Enable/disable map zoom in/out using the mouse scroll wheel.

Usage: 0 to disable or 1 to enable the map's zoom using the mouse scroll wheel. 

Default value: 1.

Example: 

[gmw_single_location object="post" scrollwheel_map_zoom="1"]

map_icon_url

The URL of the map icon/marker that represents the object's location on the map. 

Usage: Enter the URL of the image that you would like to use. 

Example: 

[gmw_single_location scrollwheel_map_zoom="1" map_icon_url="https://maps.google.com/mapfiles/ms/icons/red-dot.png"]

info_window

The elements that you would like to display in the info window ( the pop-up information window that opens with a click on the map marker ) of the object. 

Usage: enter the elements, comma-separated, that you would like to display in the info-window. Otherwise, leave it empty to disable the info-window. The elements available are distance, title, address, and location_meta ( available for the 'post' object only ).

Default value: title,address,distance.

Example: 

[gmw_single_location object="post" info_window="title,disatnce"]

user_map_icon_url 

The map icon/marker which represents the visitor's current position ( if available ) on the map. Otherwise, set it to 0 to disable this marker.

Usage: enter the URL of the image that you would like to use as the map marker.


user_info_window

The text that you would like to display in the info-window of the map marker that represents the visitor's current location. 

Usage: enter the content that you would like to display in the info-window. Otherwise, leave it empty to disable the info-window.

Default value: Your Location.

Example: 

[gmw_single_location object="post" user_info_window="You Are Here"]

no_location_message

The message that will display if no location exists for the item that is being displayed. 

Usage: enter the message that you would like to display. Otherwise, set it to 0 to hide the message. 

Example: 

[gmw_single_location object="post" no_location_message="We could't find a location"]