google maps and kml l.
Skip this Video
Loading SlideShow in 5 Seconds..
Google Maps and KML PowerPoint Presentation
Download Presentation
Google Maps and KML

Loading in 2 Seconds...

play fullscreen
1 / 21

Google Maps and KML - PowerPoint PPT Presentation

  • Uploaded on

Google Maps and KML Konstantinos Niktas COM SCI 219 Spring 2008 What is KML? KML is an XML file format “used to display geographic data in an Earth browser such as Google Earth, Google Maps, and Google Maps for mobile.”

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

Google Maps and KML

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
google maps and kml

Google Maps and KML

Konstantinos Niktas


Spring 2008

what is kml
What is KML?
  • KML is an XML file format “used to display geographic data in an Earth browser such as Google Earth, Google Maps, and Google Maps for mobile.”
  • It’s XML so it follows a case-sensitive tag-based structure with nested elements and attributes.
  • Currently in v2.1. Google has v2.2 in beta right now.
more resources
More Resources
  • KML is very extensive. It is almost a “mini programming/scripting” language itself with inheritance, types, and referencing to other files.
  • KML Documentation:
  • KML Tutorial:
  • KML 2.2 Beta:
kml elements
KML Elements
  • Everything is an “Object”. (Everything inherits from the abstract “Object” KML element).
  • There are abstract elements
  • Everything is a tag:<Point>…</Point>
  • The more advanced tags are (usually) for Google Earth.
google maps supports a subset of kml
Google Maps supports…




Descriptive HTML

KMZ (compressed KML, including attached images)

Polylines and polygons

Styles for polylines and polygons, including color, fill, and opacity

Network links to import data dynamically

Ground overlays and screen overlays

Google Maps for Mobile supports

Placemarks with <name> elements

Google Maps supports a subset of KML…
kml basics
KML Basics
  • Structure
  • Placemarks/Points/Coordinates
  • Descriptive HTML
  • Ground Overlays
  • Paths/Polygons
KML is in XML format

Usually everything contained in Document tag

Can have multiple Folder tags to separate different kinds of data. For example, one folder containing KML to show locations of pictures and another folder containing KML to show your path through the day.

placemarks points coordinates
  • The easiest element in KML.
  • A simple point on the map. It only needs a name and a location. You can give it a description too.
  • Placemark tag defines the place mark
  • A Point tag within it defines where the Placemark will be.
  • A “type” called coordinate defines the Point.
  • Coordinates in KML are given long,lat. When typing in coordinates directly into Google Maps, they are given lat,long. Be careful!
descriptive html
Descriptive HTML
  • You’ll probably want to do HTML within the description tag.
  • You need to use the CDATA tag for this. If you don’t, your HTML’s tags need to use entity references:
ground overlays
Ground Overlays
  • You can add an image onto the map. (For example, some kind of thermal map or your own satellite imagery).
  • Uses the GroundOverlay tag.
  • Defined by an image file and a LatLonBox element.
  • There are also SuperOverlays. They let you use increasingly more detailed (larger) images as you zoom in. They are much more complicated requiring multiple KML files linked together. Explained here:
  • Can define a path using the Placemark tag and the LineString tag instead of the Point tag.
  • Multiple coordinates. Again by long,lat,alt.
  • “extrude” tag makes the line go down to the ground
  • “tessellate” breaks each line into multiple pieces. Good for long lines so they don’t end up underground.
  • 0 = false, 1 = true
Defined by Polygon tag.

Can have an inner and an outer boundary

The boundaries are themselves defined by ‘LinearRing’ elements.

altitudeMode allows the polygons’ lines’ altitudes to be ‘absolute’ to sea level, ‘relativeToGround’, or ‘clampToGround’.

advanced kml
Advanced KML
  • MIME Types
  • Styles
  • Screen Overlays
  • Network Links
mime type
  • KML Servers must follow certain rules
  • Must return response code of HTTP 200
  • The type itself is:application/
  • Can set the type in PHP with: header('Content-type: application/');
  • Body must contain valid KML data and the XML declaration:<?xml version="1.0" encoding="UTF-8"?>
  • Similar to CSS/HTML styles.
  • In a Style tag. Each style tag can have multiple styles within it: LineStyle, PolyStyle, ColorStyle, etc.
  • The tag has an “id” so it can be referenced within a file or from another. (A Global KML Style file perhaps?)
  • Add a styleUrl element to use a style.
  • HW2 could have different icons based on content? A site that grabs all the Google Map icons:
  • To reference a style within the file:<styleUrl>#styleName</styleUrl>
  • Outside the file:<styleUrl>url#styleName</styleUrl>
screen overlays
Screen Overlays
  • Add an image to the Google Maps/Earth window.
  • Could be used for whatever purpose you like.
  • ScreenOverlay tag.
  • overlayXY and screenXY line up the image to the actual map
  • In this example, (0,1) (in fractions) means 0% of x (all the way to the left) and 100% of y (all the way to the top). The upper-left of the image is lined up with the upper-left of the map. The unit can also be determined by pixels.
  • Size tag (obviously) controls size of the image. 0 means to maintain aspect ratio, -1 indicate to use native dimension. Using some other value makes the image that value. For example 0.2 with units on fraction makes the image take up 20% of that dimension.
network links
Network Links
  • Allows importing of KML, KMZ, and image files for ground/screen overlays.
  • Local or remote file
  • Uses a Link tag
  • Good way to split up large KML file into much smaller KML files. More manageable.
  • More interesting feature: can use scripts to generate KML data on the fly. (PHP, Perl, etc.)
  • Usually uni-direction data flow (server to map) but when using “viewRefreshMode”, the map can pass the script information on what is being viewed (the LatLon box). Google Maps/Earth will call the script with a BBOX parameter. Look at the KML Tutorial for more information.
expert kml
Expert KML
  • Time/Animation
  • Various “Mashups”
time animation
  • We can use the TimeStamp and TimeSpan elements to add time information to any element that inherits from the Feature abstract element: NetworkLink, Placemark, ScreenOverlay, GroundOverlay, Folder, and Document.
  • TimeStamp has the element “when” inside it. A single point in time.
  • TimeSpan has two possible elements: “begin” and “end”. We can have an unbounded TimeSpan by not including “end”.
  • Times are in many possible forms: YYYY, YYYY-MM, YYYY-MM-DD, etc. (can include specific hours, minutes, time zones, etc.)
  • In Google Earth, when loading a KML/KMZ file that contains TimeStamps & TimeSpans, a time slider will appear along the top allowing an animation of the data.
  • Add the tags to your Placemarks, overlays, or whatever else you want. (As long as it’s a Feature).
  • The KML data will act like there is no time data if it is loaded into Google Maps. (Google Earth feature only).
mashups and others
“Mashups” and Others
  • Torch Relay:
  • Headline Map:
  • Placeopedia:
  • Super Skydive!
  • KML Documentation:
  • KML Tutorial:
  • KML 2.2 Beta:
  • For my example KML and PHP files, check out: