I had a few minutes of lag time, while waiting for my workstation to reboot and purge itself of virii and adware, so I tinkered for a little bit on a spare laptop. I finally got this Google Maps thing to work, using some tips from the MTGoogleMaps plugin creator, Nick Punter. Apparently, when using MTGoogleMaps and Canadian addresses, the plugin goes to the Geocoder.ca service. For this to work, you've got to insert commas between each part of the address. So instead of "123 Foobar St., Toronto, ON", you've got to use something like "123, Foobar St., Toronto, ON".

Once I confirmed that the plugin worked, I tried to do something a little more creative, like configuring it so that it would only show a Google Map in my MT blog if I wanted it there. I mean, how useless is it to render a static Google Map in your dynamically generated Main Index template? You end up with a fixed map in every single entry on your main page. What if you want a different Google Map for every blog entry? What if you don't want to display a Google Map in all of your entries? How about having a map display only when a certain field is filled in?

Well, it's a little more difficult than it looks. Here's why: Say I wanted to use the <MTEntryIfExtended> tag, so that the map would only show up in the "ExtendedEntry" section if some text were placed in the "ExtendedEntry" section -- say, a map address. That's great, but when it renders, the map code will render in the section along with the address from which the map is rendered, making a loop, and making a failure out of me. Luckily the plugin is smart enough not to render the map.

The trick is, then, to put the rendering address in another section, such as in the "EntryExcerpt" field, which I don't normally use. That way, the map address and info can be pulled from the same section, if I insert text into the "ExtendedEntry" field. Here's how the Main Index template looks:

google_maps_code.jpg

Here's how the entry looks:

google_maps_entry.jpg

And finally, here's how it rendered:

google_maps_successful.jpg

Pretty neat. Of course, this only works on the front page of the blog. If you click on the permalink, the Google Map doesn't render, and you get "ggggg" instead.

Don't know if I'm going to put this into the main blog just yet. Doing this pretty much locks both the "ExtendedEntry" and the "EntryExcerpt" fields into the MTGoogleMaps mechanism. If I ever start up a travel blog, it'd be useful there.



Leave a comment

Recent Entries

  • The Placebo Effect

    So, how's that homeopathy working for you? The Strange Powers of the Placebo Effect - YouTube...

  • Coffee and a Devil's Star

    Reading another Jo Nesbo book (is that 'Joe' or 'Yo'?) and grabbing a cup at Williams on Northfield. I'm all out of order on this...

  • 5 Reasons No One Is Guestposting At Your (My) Blog

    Image via WikipediaWell, obviously, I've not been looking for guest posters. But apparently, it's a thing you can do to get more content and more...

  • Gearing Up for the 2011 Zombie Invasion

    Image by aeviin via FlickrPut on your brains, the zombies are coming. Zombies make their appearances here and there all through the year, but you...

  • My Mai Tai

    A Trader Vic mai tai, straight from the book. Remember, the only fruit juice in a mai tai should be lime. Yes, well, there should...

Close