Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

share|improve this question
    
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

4 Answers 4

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.

share|improve this answer
    
As I've learned recently(gis.stackexchange.com/questions/4035/…), Google Maps doesnt use WGS84 projection - it's Mercator. Source: groups.google.com/group/Google-Maps-API/msg/8222b18e7921f6e6 –  radek Dec 8 '10 at 11:59
    
@ radek The google documentation says Google Earth uses WGS84 earth.google.com/support/bin/answer.py?hl=en&answer=148112 I didn't realize google maps was different (I updated my answer). –  djq Dec 8 '10 at 14:38
    
And I deleted the part about re-projection as I just realized it was irrelevant after reading Mapperz's comment. –  djq Dec 8 '10 at 14:44

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>
share|improve this answer
    
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

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

http://www.gmodules.com/ig/creator?synd=open&url=http://code.google.com/apis/kml/embed/embedkmlgadget.xml

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.

share|improve this answer

this might be helpful:

http://arcscripts.esri.com/details.asp?dbid=14273

share|improve this answer
    
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. –  iant Aug 14 '12 at 9:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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