3

Here's my code:

<html><head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <style type="text/css"> html { height: 100% } body { height: 100%; margin: 0; padding: 0 } #map-canvas { height: 500px; width: 500px; } </style> <title>Map Your Reps</title> <script type="text/javascript" src="https://maps.googleapis.com/maps/api /js?key={key}"></script> <script type="text/javascript"> function initialize() { var mapOptions = { center: new google.maps.LatLng(-34, 92), zoom: 7 }; var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions); var kmlUrl = "http://{HOST}/kml/file.kml"; var kmlOptions = { suppressInfoWindows: true, preserveViewport: false, map: map }; var kmlLayer = new google.maps.KmlLayer(kmlUrl, kmlOptions); } google.maps.event.addDomListener(window, 'load', initialize); </script> </head> <body> <h1>Map</h1> <div id="map-canvas"/> </body></html> 

For some reason, the .kml file, though publicly accessible, is not getting loaded by the API.

I notice in the network tab of the developer tools in Chrome the following request:

https://maps.googleapis.com/maps/api/js/KmlOverlayService.GetOverlays?1shttp%3A%2F%2F{HOST}%2Fkml%2Ffile.kml&callback=_xdc_._9dx071&token=97074 

The response is: /**/_xdc_._9dx071 && _xdc_._9dx071( [0,null,null,null,null,null,3,[["client","2"]]] )

When I load other KML files, this data structure represents the data from the file.

Some facts:

  • My HTML file and my KML file are both on an Amazon EC2 instance and accessible publicly ... no passwords, HTTPS, or other tricky business
  • My KML file is not compressed ... it's a real-life bonafide KML file
  • My KML file validates on kmlvalidator.com
  • My KML is 709K in size and includes polygons
  • No error messages are generated, and nothing appears on the map ... except the map itself.

I'd appreciate any assistance I can get to figure out why this KML layer isn't loading.

Thanks!

4
  • What is the status? What is the URL of the KML? Commented Jun 19, 2014 at 22:17
  • I'm having the same issue, code that worked before has stopped working with no errors. I also get back a response with nulls in it. Commented Jun 26, 2014 at 23:55
  • This question should not be downvoted it's perfectly valid. Commented Jun 25, 2015 at 19:18
  • A google employee indicated if the hosting server is too slow it will fail like this: issuetracker.google.com/issues/35823729 A public kml file from NOAA has worked fine for weeks for me but suddenly stopped working after they had network issues. Their network issues have since been resolved but the call from google still fails. Commented Mar 17, 2017 at 15:16

1 Answer 1

1

I was having the same problem (nulls in the response). It turns out I was blocking google via iptables on the server.

Sign up to request clarification or add additional context in comments.

1 Comment

You can accept your answer as the correct one. Please do so.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.