Hacking Google Maps and Google Earth (ExtremeTech)

(Dana P.) #1

Chapter 12 — The Realtors and Archaeologists Toolkit 239


Obviously the information created here is not stored and retained, but there is no reason why
the same principles shown in other chapters couldn’t be used to either generate the labels or
store the user-created labels in the system for later use. The key is in the generation and inter-
action between the user, the map, and the TLabelextension.

Overlaying Images and Drawings


In the preceding part of this chapter, the TLabelextension was used to allow text or image-
based labels to be placed onto a Google Map. The TPhotoextension enables you to overlay a
photo on top of a Google Map, either to fully replace the information shown on the map or to
augment the detail in some way.

For example, you could overlay an infrared photograph on top of the map to show particular
highlights, or perhaps use an overlay to artificially create the existence of a particular structure,
building, or object onto the map.

The former case is a good example where a localized area photo, perhaps from an archaeologi-
cal survey, could be used to enhance the information displayed on the map. Imagine if the dig
highlighted in the previous section had an aerial infrared (or perhaps underground ultra-sonic)
survey that could be overlaid precisely onto a live map of the region.

In this section the same basic method is used to overlay a very simple map of a new office com-
plex onto the same field used in the previous section. The idea is to give a live impression of the
office buildings, their location, and potential relationships with other objects on the map.

The TPhoto Extension


The TPhotoextension is from the same developer as TLabel, but unlike TLabelit is
designed as a method for overlaying an image (usually a large one) on top of a Google Map,
rather than acting as a label for a particular point on the map.

As such, unlike TLabel, the reference point for an image to be overlaid on top of the map is
based on either matching a pixel of the image with a specific latitude/longitude or matching
the top left and bottom right of the image to specific latitudes/longitudes. In the case of the
former method, anchoring a single point gives you control over the zoom level of the overlaid
image. In the case of the latter method, the anchoring of top left and bottom right of the image
determines the zoom level (the image will be located between those points and zoomed
accordingly). For the office plan overlay example, the latter method is used.

As with TLabel, you should download the JavaScript that creates the TLabel(from http://
gmaps.tommangan.us/TPhoto.html) and place the script on your own server to ensure
that it is always available. After the script has been imported into your Google Maps page, you
can configure the image to be overlaid using the following code fragment:
photo = new TPhoto();
photo.id = ‘[id]’;
photo.src = ‘[src]’;
photo.percentOpacity = [percent];
Free download pdf