Hacking Google Maps and Google Earth (ExtremeTech)

(Dana P.) #1

164 Part III — Google Map Hacks


Listing 9-11 (continued)

{
printf(‘<marker lat=”%f” lng=”%f” title=”%s”><infowindow> ;
<title>%s</title><address>%s</address><city>%s</c\ity> ;
<postcode>%s</postcode><phone>%s</phone></infowindow></marker>’,
$row->{lat},
$row->{lng},
$row->{title},
$row->{title},
$row->{street},
$row->{city},
$row->{postcode},
$row->{phone},
);

}
$sth->finish();

print(“</marker>\n”);

The result is an XML file where each restaurant is defined through XML containing the lati-
tude, longitude, and full address information:
<marker lat=”52.911400” lng=”-0.639400” title=”China Inn”>
<infowindow>
<title>China Inn</title>
<address>4 Avenue Road</address>
<city>Grantham</city>
<postcode>NG31 6TA</postcode>
<phone>01476 570033</phone>
</infowindow>
</marker>

To translate the embedded XML file, an XSL file is required. Describing the specifics of XSL
is obviously beyond the scope of this book, but you should be able to identify the basic struc-
ture of the document. Basically, the XSL in Listing 9-12 defines a structure that will convert
the embedded XML information into an HTML table.

A good source for more information on XSL is XSL Essentialsby Michael Fitzgerald (Wiley, ISBN
0-471-41620-7).
Free download pdf