Yet Another Google Maps Test

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 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:
Here’s how the entry looks:
And finally, here’s how it rendered:
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.

Comments are closed.