Skip to content

Include a Google Map embeds for the book warehouse page #40

@jbampton

Description

@jbampton

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:

  1. Install the extension: You would install the package using pip.

    pip install sphinxcontrib-googlemaps
  2. Enable the extension: In your conf.py file (the Sphinx configuration file), you need to add sphinxcontrib.googlemaps to your extensions list.

    extensions = [
        'sphinxcontrib.googlemaps',
        # ... other extensions
    ]
  3. 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 the height, width, and zoom 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

No one assigned

    Type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions