How To Add Google Maps To Your Review Site

CUSTOMIZING TEMPLATES -- Review Foundry Tutorial 08

Adjust Text:  a a a a
« Review Foundry User Manual   |   Tutorial Table Of Contents   |   Obtain Review Foundry »


CUSTOMIZING TEMPLATES

Templates

Overall, the inclusion of Google Maps related templates is just a bit more complicated that for other features in the program. This is because the content of some parsed templates needs to appear in the section of the navigation template, while other sections need to go near the closing tag. Furthermore, the content of these templates is largely javascript--make one small mistake and your Google Map disappears, leaving you wondering where the error might be. For this reason, it is not recommended that you perform more than the minimum possible modifications to the templates that go into putting a Google Map on the page.

All Template Toolkit templates that deal with Google Maps are have a common file naming format. They start with the prefix gmaps_ and can be found with all the other templates used to create public pages.

The templates that you are most likely to want to edit are the ones that determine what information from a thing record should appear in the popup window that appears when the visitor runs their mouse over a location marker. These are the "tooltip" templates, since Google refers to this popup element as a tooltip:

gmaps_tooltip_item.ttml
gmaps_tooltip_member.ttml
gmaps_tooltip_supplier.ttml

Fortunately there is NO javascript in any of these 3 templates. So if you need to adjust what appears in the popup window for a business that is represented in a map, you will want to edit the gmaps_tooltip_supplier.ttml template. In it you will find some HTML formatting for a single table that contains information for a record from the Supplier table.

In addition to the formatting for a thumnailed image, you might find a table row that contains something like the following:

[% comma = '' %]
[% newline = '' %]
[%- IF supplier.contact_phone %][% comma = ', ' %][% newline %][% newline = '
' %]<b>[% supplier.contact_phone %]</b>[% END %] [%- IF supplier.addr_street %][% comma = ', ' %][% newline %][% newline = '
' %][% supplier.addr_street %][% END %] [%- IF supplier.addr_city %][% comma = ', ' %][% newline %][% newline = '
' %][% supplier.addr_city %][% END %] [%- IF supplier.addr_zipcode %][% comma %][% supplier.addr_zipcode %][% END -%]

This is very straightforward. All the code does is check for the existence of a few fields, and, if found, a separate line is added to the table cell to display that piece of information. You would use something similar in the tooltip template for the Item or Member table.

If you can restrict your editing of the Google Maps templates to the few lines in the relevant table row shown above, you will be doing yourself a big favor. Ambitious editing is likely only to cause you a good deal of headaches when your Google Map mysteriously disappears.

Note:You will also find the following line in the template, which reformats the entire content of the template so that it may be written safely as a piece of javascript. So, do NOT alter this line:

[%- html = html FILTER replace("\n\r?","'\n+'") -%]

Changing Default Zoom Size

When a Google Map is created which shows a number of different locations, the size of the geographic window displayed needs to be automatically determined. For example, if you are viewing a page of search results, or a category listing, where there are going to be several matching locations displayed, the size of the window is preselected. This selected size might not suit you. By default the boundaries of the window are such that all locations fall within the window. However, no account is made of how close the locations may come to the window boundaries. Location markers may not fit entirely within the window. Because of this, the zoom factor that Google selects is reduced by one more factor withing Review Foundry, so that markers always fall within the window. If you do not want this zoom reduction to take place, toggle the following configuration variable to the Yes state:

gmaps_multiple_zoom_one_level

« Table of Contents


Copyright © 2004 Random Mouse Software. All Rights Reserved.