Using v3 Google Maps API
Note: The KML File(s) need to be publicly accessible - on a webserver
Google Maps API has limited KML support (simple lines, points, polygons are okay)
change: var ctaLayer = new google.maps.KmlLayer('http://gmaps-samples.googlecode.com/svn/trunk/ggeoxml/cta.kml');
ctaLayer.setMap(map);
to your kml
and the var chicago = new google.maps.LatLng(41.875696,-87.624207);
to your centre point.
http://code.google.com/apis/maps/documentation/javascript/examples/layer-kml.html
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Google Maps JavaScript API v3 Example: KmlLayer KML</title>
<link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
function initialize() {
var chicago = new google.maps.LatLng(41.875696,-87.624207);
var myOptions = {
zoom: 11,
center: chicago,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var ctaLayer = new google.maps.KmlLayer('http://gmaps-samples.googlecode.com/svn/trunk/ggeoxml/cta.kml');
ctaLayer.setMap(map);
}
</script>
</head>
<body onload="initialize()">
<div id="map_canvas"></div>
</body>
</html>
Please check the Limitations of KML/KMZ on Google Maps API:
Google Maps supports the following KML elements (that is, KML queries in the Search box and GGeoXml objects in the Maps API):
Placemarks
Icons
Folders
Descriptive HTML
Entity replacement via <BalloonStyle> and <text>
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
This list does not apply to Google Earth's export to Google Maps, My Maps import, or My Maps export to Google Earth.
The KML parser generally silently ignores XML tags it does not understand.
Google Maps currently has specific limitations to the size and complexity of loaded KML files. Below is a summary of the current limits:
Note: these limits are temporary and are subject to change at any time.
Maximum fetched file size (raw KML, raw GeoRSS, or compressed KMZ) 3MB
Maximum uncompressed KML file size 10MB
Maximum number of Network Links 10
Maximum number of total document-wide features 1,000
Best Answer
You cannot extract data from Google Maps.
What you could do, is to get the data from other sources. Depending on your Area of interest, the boundary might be available from your local government agency, or even OpenStreetmap.