Hacking Google Maps and Google Earth (ExtremeTech)

(Dana P.) #1

Chapter 12 — The Realtors and Archaeologists Toolkit 233


var mapcontrols;
var lastpoint;
var objectfinds = [];
var trenchs = [];
var ruins = [];


Setting Up the Map


For the location you’ll use a bare field outside Oklahoma City. It happens to be clear and a
uniform size, although of course the map could be located anywhere. The mapping information
is irrelevant; you want to be able to compare the lay of the land with the archaeological finds.
The Google Satellite photos can actually show quite a lot of information. For example, some
buried elements are only visible from the sky and then only because the coloration of the land
changes or minor variations in height change the appearance of the land when photographed.
As far as I know, the field being used here has no archaeological features, although you can see
patterns on the ground, probably the result of small hills and/or the effects of farming.


Unfortunately, there is not yet enough of the U.K. viewable at high enough quality to examine
some of the sites I know well where the information is visible, so you’ll work with the fake
farmland dig using this field.


To start, you zoom right in to the field, switch the display type for the map using
setMapType(), and then create the event listener that will record map clicks. Each time
the map is clicked, the function is called, supplying the object overlay and the point where the
user clicked. It is the latter item that needs to be recorded, and this is placed into the global
variable:


function onLoad() {
if (GBrowserIsCompatible()) {
selpanel = document.getElementById(“selections”);
mapcontrols = document.getElementById(“mapcontrols”);
map = new GMap(document.getElementById(“map”));
map.setMapType(G_SATELLITE_TYPE);
map.centerAndZoom(new GPoint(-97.58790493011475, 35.28039711620333), 1);
map.addControl(new GLargeMapControl());
GEvent.addListener(map, ‘click’, function(overlay,point) {
lastpoint = point;
});
}
}


Adding a Label


The main function is addpoint(), which accepts a single argument, the type of point to
be added to the map. The type is referenced in the link that the user clicks to generate the
TLabelobject. The different types adjust two elements: the background color of the label
that is created and, in the case of the vase, the inclusion of the vase image in place of the text
description.

Free download pdf