How To Add Google Maps To Your Review Site

CUSTOMIZING MARKERS -- Review Foundry Tutorial 08

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


CUSTOMIZING MARKERS

Markers

A marker in a Google Map is an icon that sits over the spot on the map at which a business, or other locality of interest, is located. Usually it has a pointed end that indicates the exact point where the latitude and longitude associated with the location is to be found. A marker is therefore like a location pushpin stuck into the map. Google tries to emphasize this by making the marker look like it sits above the map, even adding a shadow to help with the 3-D effect.

The topic of markers in the Google Map API is a subject unto itself. It is unlikely that you would want to attempt to modify the markers that Review Foundry uses unless you are an expert in the field of the Google Maps API. However, a few things will be said about the markers so that you have a good idea about how it all works, should you need to attempt modications.

The main complication with markers is that you really need to be able to write something on them, so that you can distinguish between each one when looking at a map that shows multiple locations. Because the Google Map API requires that you provide the URL to each marker icon, you either have to produce these markers on the fly (depending on how they are to be labeled) or you have to determine which ones are to be used from a pregenerated set. Review Foundry does exactly that. If a marker icon has not yet been generated and cached for use, one is created and stored in the following directory in your document root:

/rs/foundry/google/icons/

In fact, you will find two subdirectories: /main for the normal icon, and /hover for the icon displayed when the mouse rolls over it (generating a change of icon color).

Review Foundry makes a call to the GD image library embedded in your PHP environment. So if you do not have up-to-date PHP you might find your icons cannot be generated. So fix that problem! You can test whether your PHP is able to create icons on the fly successfully by going to the Configure > Google Maps page. You will see a section dedicated to marker icons which are numbered. On the left are test images that come with the Review Foundry install, and on the right are images generated on the fly via PHP. If the two sets do not match you have a problem. Consult with your web host on how to fix that.

It should be noted that all marker icons generated by Review Foundry are PNG image files with alpha channel transparency.

The PHP script that generates an icon has the following path in your document root:

/rs/foundry/skins/default/php/make_marker.php

It takes as input an s (or string) variable, so that you can generate a marker icon with the label '123' by typing the following URL into your browser:

http://www.yoursite.com/rs/foundry/skins/default/php/make_marker.php?s=123

If you have not changed the deault colors for a marker icon, you should see main and hover images that look just like these:


main image 123
main icon
hover image 123
hover icon

To change the color to the current "hover color", add &hover=1 to the query string. Use the make_marker.php script for testing. If you really need to edit the appearance of generated marker icons you would edit the library used by this script. The library is named make_marker_lib.php (though you had better know what you are doing before touching it).

Marker Shadows

Google allows you to specify a shadow icon to go with the icon image representing the marker. If all markers were of identical size and shape, a single shadow image could be used. But that is not the case in Review Foundry, where the icon image changes, depending on the length of the label which is printed on it. Presently, a maximum of 5 characters can appear in the string making up the icon label. That means there are 5 possible shadows that an icon can cast. These are shown below for the default marker representation, and they are automatically placed on a Google Map as needed.

These shadow files are stired in the following directory, and need to be replaced with more suitable images if the icon generation machinery is modified to produce icons with different shape/size from the default implementation:

/rs/foundry/skins/default/images/misc/

Creating Markers In Bulk

You can make some adjustment to the colors used in the generation of marker icons by visiting the Configure > Style / Colors page. Once you have settled on an appropriate color scheme you can pregenerate all the markers you are ever likely to need. The command line script that should be invoked for this can be found in the same directory as the on-the-fly script. Its path is:

/rs/foundry/skins/default/php/make_all_markers.php

It can be invoked from the command line by navigating to the /php directory and typing:

> php make_all_markers.php

This will take a little while to do, as the script will generate 100,000 main icons and the corresponding 100,000 hover icons. You will see a progress report printed to the screen as it works its way through. Here is the documentation from the top of that script if you should need to generate fewer icons (in which case you need to edit the file directly):

/*
make_all_markers.php

Generates PNG files in bulk to be used as Google Maps marker icons.

This script can be run ONCE from the command line like so:

    php make_all_markers.php

and it will generate all the numbered icons to be used by RQ when
creating Google Map images. You can modify the total number of
icons to be generated and the (batch) number at which a progress
indicator is written to screen. For example:

    $total_images = 100;
    $batch_size = 10;

This means create 100 main icons and 100 hover icons, and report
the number generated so far every time another 10 icons has been
created.

If this script is never run, RQ will simply create the icons when
needed and cache them for later use.

*/

If you pregenerate icons in bulk and then decide to change the colors, simply delete the corresponding icon directories and rebuild.

Next Section: CUSTOMIZING TEMPLATES

« Table of Contents


Copyright © 2004 Random Mouse Software. All Rights Reserved.