CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-gmaps

Google maps plugin for Jupyter notebooks with interactive visualization capabilities

Pending
Overview
Eval results
Files

markers.mddocs/

Marker and Symbol Layers

Display point data using markers and customizable SVG symbols with hover text, info boxes, and flexible styling options. Markers are perfect for showing specific locations like businesses, landmarks, or events.

Capabilities

Marker Layer Creation

Create layers containing traditional Google Maps markers with labels and info boxes.

def marker_layer(locations, hover_text='', label='', info_box_content=None, display_info_box=None):
    """
    Create a layer of markers.

    Parameters:
    - locations (array-like): Array of (latitude, longitude) tuples
    - hover_text (str or list): Text to display on hover
    - label (str or list): Text displayed inside marker
    - info_box_content (str or list, optional): Content for info box popup
    - display_info_box (bool or list, optional): Whether to show info box on click

    Returns:
    Markers: Markers layer instance
    """

Symbol Layer Creation

Create layers with customizable SVG symbols for more flexible point visualization.

def symbol_layer(locations, hover_text='', fill_color=None, fill_opacity=1.0, stroke_color=None, stroke_opacity=1.0, scale=3, info_box_content=None, display_info_box=None):
    """
    Create a layer of symbols (SVG markers).

    Parameters:
    - locations (array-like): Array of (latitude, longitude) tuples
    - hover_text (str or list): Text to display on hover
    - fill_color (str or list, optional): Symbol fill color
    - fill_opacity (float or list): Fill opacity (0.0-1.0)
    - stroke_color (str or list, optional): Symbol outline color
    - stroke_opacity (float or list): Stroke opacity (0.0-1.0)
    - scale (float or list): Symbol size scaling factor
    - info_box_content (str or list, optional): Content for info box popup
    - display_info_box (bool or list, optional): Whether to show info box on click

    Returns:
    Markers: Markers layer instance containing symbols
    """

Individual Marker Widget

Single marker widget with customizable appearance and interaction.

class Marker:
    """
    Individual marker widget.
    
    Attributes:
    - location (tuple): (latitude, longitude) tuple
    - hover_text (str): Mouse hover text
    - label (str): Text displayed inside marker
    - display_info_box (bool): Whether to show info box on click
    - info_box_content (str): Content for info box
    """

Individual Symbol Widget

Single symbol widget for SVG-based markers with styling options.

class Symbol:
    """
    Individual symbol widget (SVG-based marker).
    
    Attributes:
    - location (tuple): (latitude, longitude) tuple
    - fill_color (str): Symbol fill color
    - fill_opacity (float): Fill opacity (0.0-1.0)
    - stroke_color (str): Symbol outline color
    - stroke_opacity (float): Stroke opacity (0.0-1.0)
    - scale (float): Symbol size scaling factor
    - hover_text (str): Mouse hover text
    - info_box_content (str): Content for info box
    - display_info_box (bool): Whether to show info box on click
    """

Markers Container

Container widget for managing multiple markers or symbols.

class Markers:
    """
    Container for multiple markers/symbols.
    
    Attributes:
    - markers (list): List of Marker or Symbol instances
    """

Marker Styling Options

Reusable styling configuration for markers.

class MarkerOptions:
    """
    Style options for markers.
    
    Attributes:
    - hover_text (str): Default hover text
    - display_info_box (bool): Default info box behavior
    - info_box_content (str): Default info box content
    - label (str): Default marker label
    """
    
    def to_marker(self, latitude, longitude):
        """
        Create marker with these options.

        Parameters:
        - latitude (float): Marker latitude
        - longitude (float): Marker longitude

        Returns:
        Marker: Configured marker instance
        """

Usage Examples

Basic Markers

import gmaps

gmaps.configure(api_key="YOUR_API_KEY")

# Define locations
locations = [
    (37.7749, -122.4194),  # San Francisco
    (37.7849, -122.4094),  # Another point
    (37.7649, -122.4294)   # Third point
]

# Create marker layer
fig = gmaps.figure()
marker_layer = gmaps.marker_layer(locations)
fig.add_layer(marker_layer)
fig

Markers with Labels and Info Boxes

import gmaps

gmaps.configure(api_key="YOUR_API_KEY")

locations = [(37.7749, -122.4194), (37.7849, -122.4094)]
labels = ['A', 'B']
hover_texts = ['San Francisco City Hall', 'Golden Gate Park']
info_box_content = [
    'San Francisco City Hall<br>Built in 1915',
    'Golden Gate Park<br>1,017 acre urban park'
]

fig = gmaps.figure()
marker_layer = gmaps.marker_layer(
    locations,
    hover_text=hover_texts,
    label=labels,
    info_box_content=info_box_content,
    display_info_box=True
)
fig.add_layer(marker_layer)
fig

Styled Symbol Layer

import gmaps
import numpy as np

gmaps.configure(api_key="YOUR_API_KEY")

# Generate sample data
np.random.seed(42)
num_points = 50
lat_center, lng_center = 37.7749, -122.4194
locations = np.random.normal(
    [lat_center, lng_center], 
    [0.01, 0.01], 
    (num_points, 2)
)

# Create color-coded symbols based on data values
values = np.random.rand(num_points)
colors = ['red' if v > 0.5 else 'blue' for v in values]
scales = [2 + 3 * v for v in values]  # Scale based on value

fig = gmaps.figure()
symbol_layer = gmaps.symbol_layer(
    locations,
    fill_color=colors,
    fill_opacity=0.7,
    stroke_color='black',
    stroke_opacity=1.0,
    scale=scales,
    hover_text=[f'Value: {v:.2f}' for v in values]
)
fig.add_layer(symbol_layer)
fig

Mixed Marker Types

import gmaps

gmaps.configure(api_key="YOUR_API_KEY")

fig = gmaps.figure()

# Add traditional markers
marker_locations = [(37.7749, -122.4194), (37.7849, -122.4094)]
markers = gmaps.marker_layer(
    marker_locations,
    label=['City Hall', 'Park'],
    hover_text=['Government Building', 'Recreation Area']
)
fig.add_layer(markers)

# Add colored symbols
symbol_locations = [(37.7649, -122.4294), (37.7949, -122.3994)]
symbols = gmaps.symbol_layer(
    symbol_locations,
    fill_color=['green', 'orange'],
    scale=[4, 6],
    hover_text=['Location C', 'Location D']
)
fig.add_layer(symbols)

fig

Individual Marker Creation

import gmaps

gmaps.configure(api_key="YOUR_API_KEY")

# Create individual markers
marker1 = gmaps.Marker(
    location=(37.7749, -122.4194),
    label='1',
    hover_text='First location',
    info_box_content='This is the first marker'
)

marker2 = gmaps.Symbol(
    location=(37.7849, -122.4094),
    fill_color='red',
    scale=5,
    hover_text='Second location'
)

# Create markers container
markers_layer = gmaps.Markers(markers=[marker1, marker2])

fig = gmaps.figure()
fig.add_layer(markers_layer)
fig

Install with Tessl CLI

npx tessl i tessl/pypi-gmaps

docs

datasets.md

directions.md

drawing.md

figure-map.md

geojson.md

heatmap.md

index.md

markers.md

transportation.md

tile.json