Maps API Blog

Wednesday, November 23, 2005
at
11:22:00 AM

Thanksgiving is upon us here in the US... Time for turkey, stuffing, and, of course, Maps API turkey icons with perfect 45-degree shadows:

Creating custom markers for the Maps API is easy in terms of programming and hard in terms of graphic design. We use a custom Adobe Photoshop action internally to produce accurate marker shadows. I have been pestering our UI wizard Jens to let me publish the action publicly so that we start seeing prettier shadows on API sites, but right now using the action requires a PhD in Photoshop and a Post Doc in How Jens’ Mind Works. He assures me that we will release a simpler version of the action by the end of the year.

In the meantime, here is a basic step-by-step guide, though you are still on your own in creating nice-looking shadows:

Note: The images displayed below are 24-bit PNGs with alpha transparency, so they may look incorrect in Internet Explorer. However, the Maps API code snippets below should work in all browsers.

Create your marker image. It should be a 24-bit PNG image so that it supports true alpha transparency. This is important so that the icon is properly anti-aliased and still looks good on top of the map. Here is our turkey marker foreground image (59x62 pixels):

Now create your shadow. You should add padding around the shadow so that the shadow is in the correct position when you line up the top-left pixels of the icon and shadow images. Here is our shadow image (91x62 pixels):

And here is the icon image overlaid in the correct position on top of the shadow image:

Finally, decide where you want the icon to be anchored to the map and where you want the info window to be anchored to the icon. Most icons have a well-defined "tip" at which they should be anchored. Since our turkey has an odd shape, we just choose a point between the turkey's feet. The Maps API expects this coordinate to be measured from the top-left pixel of the marker. So, in the case of our turkey icon, we choose the icon anchor point (37, 59) because our anchor point is 37 pixels over and 59 pixels down from the top-left pixel of the turkey icon. Likewise, we choose (31, 8) for the info window anchor point because we want the info window to be attached to the turkey's head:

And you are done! Once you have created your images and chosen your anchor points, you tie them together with code like this: