-
-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Yes, you can include a Google Map embed on your Sphinx site. The most common and effective way to do this is by using a third-party Sphinx extension.
The extension sphinxcontrib-googlemaps
is a popular choice specifically designed for this purpose. It allows you to use a directive in your reStructuredText (.rst
) files to embed maps with a simple syntax.
Here's a general idea of how it works:
-
Install the extension: You would install the package using
pip
.pip install sphinxcontrib-googlemaps
-
Enable the extension: In your
conf.py
file (the Sphinx configuration file), you need to addsphinxcontrib.googlemaps
to yourextensions
list.extensions = [ 'sphinxcontrib.googlemaps', # ... other extensions ]
-
Add the map directive: In your
.rst
file where you want the map to appear, you would use a directive like this:.. googlemaps:: your_location_or_address :height: 400 :width: 600 :zoom: 15
The
your_location_or_address
part is where you'd put the address, coordinates, or name of the place you want to show on the map. You can also specify theheight
,width
, andzoom
level.
Why use an extension?
Sphinx and reStructuredText are primarily for generating documentation. While you can include raw HTML directly, a dedicated extension provides a cleaner, more maintainable, and re-usable way to embed dynamic content. It abstracts away the raw HTML and JavaScript code from the user, allowing you to focus on the content and location of the map.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status