Hacking Google Maps and Google Earth (ExtremeTech)

(Dana P.) #1

Chapter 12 — The Realtors and Archaeologists Toolkit 235


<div style=”background-color: #f2efe9; padding: 2px;”> ;
<img src=”woodvase.png” alt=”” style=”border: none;”></\div>

’;
}


If the entity isn’t a vase, the content of the input box is checked and the content is then popu-
lated. If the input box is empty, a warning is raised and no label is created.


else {
if (entityname.value.length == 0) {
alert(‘You must give this point a name’);
return;
}

var content = ‘<div style=”padding: 16px 24px 0px 0px; ;
background: url(topright.png) no-repeat top right;”><div style= ;
“background-color: ‘ + color + ‘; padding: 2px; font-size: 0.7em;”> ;
<div style=”color: #0000ff; font-weight: bold”>’ + pointtype + ;

’ + entityname.value + ‘
’;
label.content = content;
}


Finally, the label is added to the map:


map.addTLabel(label);
}

An alert is raised if the map has not been clicked and a point has not been created:


else {
alert(“No point has been set”);
}
}


Showing and Hiding Points


To show and hide the points, links on the main page call the showpoints()and
hidepoints()functions, which accept the name of an array and iterate through the objects,
showing or hiding them as appropriate:


function showpoints(pointtype) {
for(var i=0;i<pointtype.length;i++) {
map.addTLabel(pointtype[i]);
}
}


function hidepoints(pointtype) {
for(var i=0;i<pointtype.length;i++) {
map.removeTLabel(pointtype[i]);
}
}

Free download pdf