Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Give Your Applications Mapping Capabilities, Part 2

Learn to write applications that render static and real-time data positional data with Google Earth.


advertisement
oogle Earth (GE) provides a powerful 3D environment that you can use to provision your application with rich interactive 3D features. You can render points, lines or areas located at any point on earth—using either local, static, or positional data downloaded from the web. Your web applications publish the data to create useful maps or other information. You can also write files that cause GE to download data from your web site repeatedly, letting you show real-time positions.

Understanding Google Earth KML
GE works with XML in a form called the Keynote Markup Language (KML). You write KML documents to render data in GE. Because KML is a simple text-based format, you can use any programming language or text editor tool to create the KML files. KML lets you manage and render geo-information without having to know the details of how Google renders maps and data points.

Author's Note: The downloadable code for this article is in VB.NET, but all it does is create KML files, so you should be able to translate it to C# or another language fairly easily.

Here's the same simple KML file from Part 1 of this two-part article with a little more detail about its construction:

<?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://earth.google.com/kml/2.2"> <Document> <name>Arena di Verona</name> <Placemark> <name>Arena di Verona</name> <LookAt> <longitude>10.99394514599905</longitude> <latitude>45.44023503220072</latitude> <altitude>200</altitude> <range>759.5637314343327</range> <tilt>58.7902038199754</tilt> <heading>0.8203667851755632</heading> <altitudeMode>relativeToGround</altitudeMode> </LookAt> <Point> <coordinates>10.99451099760466,45.43891075160266,0</coordinates> </Point> </Placemark> </Document> </kml>

The root element is <Document>, which contains a <Placemark> element that holds a name, and the "camera" or view position from which to look at a point of interest on earth. Points (consisting of latitude, longitude, and altitude values) are the most basic type of geographical information. The <Point> element in the KML contains the values for the point the "camera" will look at. GE works with the latitude, longitude, and altitude of a point as three real numbers, written as a plain comma-delimited string. Note that order is significant; points are always specified in latitude, longitude, altitude sequence. The number format (using a period to separate the integer portion of a number from the fractional portion) and the comma separator are culture invariant.

In sum, the KML example actually defines two points. The <LookAt> "camera" point, which has separate nodes for latitude, longitude, altitude, and other data, is an exception to standard GE coordinate rules. The <Point> geographic point, with its comma-separated values, specifies the point data in a typical manner.

Author's Note: KML defines all data as XML nodes, but points or lines require you to define coordinates as a plain string with all data comma separated. This "non-xml" approach to coordinate management is to improve performance and reduce data volumes. Files with many points (for example those that define a line) would otherwise require huge KML files.

Please note every object on earth in GE is defined as a "Placemark." Therefore, to show a point (as in the previous example) you need to define a "point-placemark;" to show a line or a polygon you define a "linestring-placemark," or a "polygon-placemark," respectively. But remember that the base node is always <Placemark>.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap