I would like to show a map on my website. I have 2 different kinds of KML files that need to be plotted. One defines region boundaries. The other points within those boundaries. The region boundaries are in standard google map format. The points are in "EPSG:4326" format.

Is google maps the right tool for the job or should I use something else? I heard openlayers is an alternative.

  • as long as the KML has latitude & longitude coordinates in decimal degrees it will not matter about EPSG:4326 – Mapperz Dec 8 '10 at 3:31

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.


<!DOCTYPE html>
<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');
<body onload="initialize()">
  <div id="map_canvas"></div>

  • This is great Mapperz thank you. I was able to successfully plot one of my KML files to the map. The one I know was made for google maps. However, the other KML is not showing up at all. This is one that is in a different projection. Is there a way of changing or specifying the project format? – aaronfarr Dec 8 '10 at 18:43
  • 1
    No all data needs to be projected to WGS84 for overlaying on Google and Bing Maps. To add another KML layer - var ctaLayer2 = new google.maps.KmlLayer('yourother.kml'); ctaLayer2.setMap(map); – Mapperz Dec 8 '10 at 19:50

Google maps is certainly one way of displaying KML files on a website, and it is quite easy. The documentation of google maps is good (see here); I haven't used openlayers so cannot compare.


You could combine the two kml files together and then put the result into the Google Earth API, no coding required via this gadget:


In this instance GEarth has the advantage that you can see the terrain in 3D (if that's important) but the disadvantage that on a global scale you can't see all the data at once.


this might be helpful:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.