Embed maps in your Sphinx documents using a locally-stored KML file.

pip install sphinx-kml==0.1.3



Embed maps in your restructuredText documents using locally-stored KML files.


Install from pip --

pip install sphinx-kml

Make the following alterations to your Sphinx project's conf.py:

extensions = [
    # other extensions
google_api_key = 'MYGOOGLEAPIKEY'
# Assuming you copied the aforementioned kmlmapparser files to the 'static/'
# directory in your project:
html_static_path = ['static/', ]

Basic Use

Just use the kml directive with the relative path to a KML file you would like to render; assuming you have put a file named some_kml_file.kml in the resources/ subdirectory:

.. kml:: resources/some_kml_file.kml


You can also set the following options to customize the display of your KML map:

  • center: (Default: center of your provided KML file's contents) If you would like to set a different center point, you can provide a floating-point latitude and longitude (separated by a space).
  • height: (Default: 500) The pixel height of the generated map.
  • type: (Default: 'satellite'; default can be overridden by setting the default_map_type configuration setting) Map type to display. Options include 'satellite', 'roadmap', 'hybrid', and 'terrain'.
  • zoom: (Default: a zoom level capable of displaying all KLM points) If you would like to set a different zoom level, use this.
  • zoomonclick: (Default: true) Whether clicking on a displayed point should zoom-in on the point.


.. kml:: resources/echolink.kml
   :center: 44.739346 -124.057617
   :zoom: 8
   :zoomonclick: false