Hacking Google Maps and Google Earth (ExtremeTech)

(Dana P.) #1

Chapter 16 — Generating Google Earth Feeds 321


<?xml version=”1.0” encoding=”UTF-8”?>
<kml xmlns=”http://earth.google.com/kml/2.0”>
<Document>
<visiblity>1</visbility>
<NetworkLink>
<name>ExtremeTech Google Maps: Grantham Entities</name>
<Url>
<href>http://maps.mcslp.com/examples/ch16-03.cgi</href>
<refreshMode>onInterval</refreshMode>
<refreshInterval>300</refreshInterval>
<viewRefreshMode>onStop</viewRefreshMode>
<viewRefreshTime>7</viewRefreshTime>
</Url>
</NetworkLink>
</Document>
</kml>

Looking at the individual elements, you can pick out the main points. First, you define the
name of the network link:
<name>ExtremeTech Google Maps: Grantham Entities</name>

Then you specify the URL, the refresh mode, the interval (specified in seconds), and the view-
ing format. Open the KML file in Google Earth, and the dynamic KML will automatically be
loaded.

Adding Icons


You can stylize a <Placemark>tag with a custom icon by using the Styleelement. The
Styleelement enables you to set custom styles for a <Placemark>tag. The IconStyle
element defines the icon details. For example:
<Style>
<IconStyle>
<Icon>
<href>http://maps.mcslp.com/examples/bank.png</href>
</Icon>
</IconStyle>
</Style>

The <href>element defines the location of the icon graphic. In this case, the location speci-
fied is the same as that used for the Bank icon example demonstrated in Chapter 11. You can
use a single source file for the icon and extract the icon using the x/y reference of the left/bot-
tom edge and the height and width of the icon (using the <h>and <w>tags).

For the final example, you’ll use a simple icon, chosen using the type name to generate the
icon, just as used in Chapter 11. The resulting script is shown as follows:
Free download pdf