and like us on FB

This article will provide you with a WordPress function that’ll permit you to post Google Maps inside of your WordPress post or page using shortcode. It’s ported over from the retired Internoetics, but it still works (despite being a little dated). You’re required to register for an API key, and you should register your embed page and/or server IP to ensure your key isn’t abused if publicly displayed.

The Result

Using the shortcode of [googlemap src="8 cavendish st concord west nsw 2138"] we’ll render the following map (the address is one formerly owned by family).

Available attributes are detailed below. The shortcode should be modified to your preferred defaults so you’ll only ever need to specify the src (address).

WordPress Shortcode

Copy and paste the WordPress function into your theme's functions.php file or, if you sensibly have one installed, your custom functions plugin.

If you require shortcode to work in a sidebar widget, you'll have to enable the functionality with a filter. If you're using our custom functions plugin, you'll have that feature enabled by default.

Shortcode Attributes

Once you’ve copied the code as required, the only attributes that are really required are width, height and src. Once width and height are set, it’ll only be src (address) that’s ever required in your shortcode. Other options are not required.

Available attributes are as follows:

width

The width of the Google Map (iframe). It should normally be set to a little less than the width of your post container. By default, it will center.

height

The height of the iframe.

src

The address or location you wish to render on your website. Can include spaces (we’ll replace spaces as required when the code is evaluated).

maptype

maptype can be either roadmap (the default) or satellite, and defines the type of map tiles to load.

apikey

Required. Register for a free key here .

zoom

If set, zoom will set the initial zoom level of the map. Accepted values range from 0 (the whole world) to 21 (individual buildings). The upper limit can vary depending on the map data available at the selected location.

center

center defines the center of the map view. It accepts a comma-separated latitude and longitude value (such as 37.4218,-122.0840).

language

language defines the language to use for UI elements and for the display of labels on map tiles. Note that this parameter is only supported for some country tiles; if the specific language requested is not supported for the tile set, then the default language for that tileset will be used. By default, visitors will see a map in their own language.

region

region defines the appropriate borders and labels to display, based on geo-political sensitivities. Accepts a region code specified as a two-character ccTLD (top-level domain) value.

Another Example

Using some of the available attributes, here’s another look at the old address (the old house is replaced by dodgy townhouses). Shortcode used is as follows: [googlemap src="8 moala st concord west nsw 2138" zoom="19" maptype="satellite"].

We’ll update the code soon.

Shortt URL for this post: http://shor.tt/Dyi