How to add a Google MyMaps to the Google Maps v3 Shortcode plugin

The easiest way to create a custom KML is using Google’s “My Maps” feature.  Assuming you already have a MyMaps created, you can use it with this plugin by following these steps:

Grab the KML of your My Map

Go to your My Maps page, and select the map you want to use.  Then, click on the “edit” button as shown below:

A link to Google Earth should now appear above the map.  Right click on the link, and copy the link.

Add the KML to the shortcode

Now add that link to the shortcode like this:

[ map w="500" h="400" maptype="SATELLITE" kml="http://maps.google.com/maps/ms?ie=UTF8&hl=en&vps=2&jsv=295c&msa=0&output=nl&msid=106943900362299320636.00047ede6cd99f793ce99" ]

WordPress Plugin: Google Maps v3 Shortcode

This plugin allows you to add a google map into your post/page using shortcodes. The following examples shows all available parameters you can use in your shortcode. Note that these examples have spaces between the opening and closing square brackets that must be removed during actual implementation.

http://wordpress.org/extend/plugins/google-maps-v3-shortcode/

If you like this plug-in, please consider donating! It will help buy me some coffee to keep me awake :)

Features

  • Support for Google MyMaps
  • Info windows
  • multiple maps on the same post
  • set map size
  • set zoom level
  • set map type
  • set location by latitude/longitude
  • set location by address
  • add marker
  • add custom image as map icon
  • add KML via URL link
  • show traffic
  • NEW!show bike lanes
  • NEW!add a Fusion Table Layer
  • NEW!show infowindow by default

Default world map

[ map ]

Multiple maps on the same page

In order to add more than one map to the same page, you need to add an “id” parameter for the new map.  Since the default id for the first map is “map”, make sure you name it something else (ex: “map1”, “map2”).  All id’s on the same page must be unique.

[ map id="map2"]

Width/Height

Default width value = 400, default height value = 300 (in pixels)

[ map id="map3" w="200" h="100" ]

Zoom level

Default value = 1

[ map id="map4" z="5" ]

Map Type

Default value = ROADMAP Accepted values = ROADMAP | SATELLITE | HYBRID | TERRAIN

[ map id="map5" z="5" maptype="TERRAIN" ]

Latitude/Longitude

Default value = 0,0

[ map id="map6" z="5" lat="34" lon="-118" ]

Address

If you provide an address, it will override any lat/lon parameters.

[ map id="map7" z="5" address="Tokyo, Japan" ]

Marker

[ map id="map8" z="5" address="Tokyo, Japan" marker="yes"]

Marker Image

You can add your own custom image to override the default google map icon.  Make sure to keep your image small.  Also, I would recommend you use a .gif or .png format with transparency.  If you use your own image, make sure to also add the marker=”yes” parameter.

[ map id="map9" z="5" address="Tokyo, Japan" marker="yes" markerimage="http://code.google.com/apis/maps/documentation/javascript/examples/images/beachflag.png"]

Info Window

If you have set marker=yes then you can also choose to provide an info window bubble.  Simple HTML tags are also supported.

NOTE: Info window stying is very finicky in terms of the syntax. Try using < span > tags instead of < div > tags, and try to avoid double and single quotes.

[ map id="map10" z="15" address="New York" marker="yes" infowindow="Hello World
New York is the most populous city in the United States, and the center of the New York metropolitan area, which is one of the most populous metropolitan areas in the world."
]

KML

Adding a KML URL will override any address or lat/lon parameters. It will also auto-center and zoom to the extent of the KML, therefore, overriding any zoom level settings.

[ map id="map11" z="5" kml="http://gmaps-samples.googlecode.com/svn/trunk/ggeoxml/cta.kml" ]

Traffic

[ map id="map12" z="5" address="Los Angeles, USA" traffic="yes" ]

How To Setup Multisite/Network in WordPress

WordPress v3.0 allows you to host multiple sites in a single install (previously MU).  I followed the instructions on how to set this up following the WordPress documentation:

http://codex.wordpress.org/Create_A_Network

However, for some reason, these instructions did not work on a sub-directory install.  I got the following message after hitting the “network” link in the Tools dashboard:

Because your install is not new, the sites in your WordPress network must use sub-domains

I had to follow these instructions to finally get it to work:

In WordPress 3.0, we have the ability to create a network of sites. But if your install is over 1 month old, the sites in your WordPress network must use sub-domains because of permalink problems with “/blog/” from the main site. This is how you can force the sites in your WordPress network to use sub-directories during the Network installation process.

Add the following lines to your current activated WordPress Theme’s template file, preferably your Theme’s template functions.php file:

add_filter( 'allow_subdirectory_install',
	create_function( '', 'return true;' )
	);

You can remove the lines above once you done enabling the Network feature.

Creating this into a plugin is not an option, since all plugins are required to be deactivated before enabling the Network feature. Please read on how to Create A Network in the WordPress Codex and ticket #12931 for more information on why it is block by default.

How To Create Separate Sidebar Widgets Per Page in WordPress

Widgets area in wordpress admin

Most WordPress themes come with the “Widgets” function in the dashboard (Appearance –>  Widgets), that allows you to control the sidebars for all your site pages.  However, for the most part, these are global settings, in other words, for every page in your site, it will apply the widgets accordingly.

So how do you set different widgets to show up on different pages of the site?  Here is one work flow that worked for me:

  1. Create different templates for each page layout you want.  For example, you might have a 2 column layout page and a 3 column layout page.  Each layout would have different content you want to appear in their sidebars.  You would then create two templates:  2-column-layout and 3-column -layout.
  2. When you create the template file, add the following code where you would like to see be controlled by widgets.  For example, if you want a widget controlled right side bar for your two column template, then add the following code:
    <?php if (!function_exists('dynamic_sidebar') ||
    !dynamic_sidebar('two-column-right')) { ?>
  3. Now you must tell WordPress Widgets to recognize your new sidebar entry.  Open Functions.php, and add the following code:
    if (function_exists('register_sidebar')) {
           register_sidebar(array(
                   'name' => 'two-column-right',
                   'id' => 'two-column-right',
                   'before_widget' => '<div class="widget">',
                   'after_widget' => "</div>",
                   'before_title' => "<h4>",
                   'after_title' => "</h4>",
                   ));
    }
  4. Create the pages in your site, and make sure to choose the correct template.
  5. Now go the wordpress admin section, click on Appearance –> Widgets, and you should see your new side bar entry “two-column-right”.

Sources: http://automattic.com/code/widgets/themes/