Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,8 @@ node_modules
.npm

# Optional REPL history
.node_repl_history
.node_repl_history

# Build output (keep dist/leaflet-mapbox-gl.d.ts as it's hand-written)
dist/*.js
dist/*.js.map
12 changes: 12 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"esversion": 11,
"module": true,
"browser": true,
"node": true,
"undef": true,
"unused": true,
"globals": {
"L": true,
"mapboxgl": true
}
}
94 changes: 94 additions & 0 deletions dist/leaflet-mapbox-gl.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import * as L from 'leaflet';
import * as mapboxgl from 'mapbox-gl';

declare module 'leaflet' {
interface MapboxGLOptions extends L.LayerOptions {
/** Mapbox access token */
accessToken?: string;
/** Mapbox style URL or style object */
style?: string | mapboxgl.StyleSpecification;
/** Update interval in milliseconds (default: 32) */
updateInterval?: number;
/** Padding around the map view (default: 0.1) */
padding?: number;
/** Enable mouse/keyboard events on the mapbox overlay (default: false) */
interactive?: boolean;
/** Custom class name for the canvas element */
className?: string;
/** Minimum zoom level */
minZoom?: number;
/** Maximum zoom level */
maxZoom?: number;
}

class MapboxGL extends L.Layer {
constructor(options: MapboxGLOptions);
options: MapboxGLOptions;

/** Get the underlying Mapbox GL map instance */
getMapboxMap(): mapboxgl.Map;

/** Get the canvas element */
getCanvas(): HTMLCanvasElement;

/** Get the size of the layer */
getSize(): L.Point;

/** Get the bounds of the layer */
getBounds(): L.LatLngBounds;

/** Get the container element */
getContainer(): HTMLDivElement;

/** Get the pane name */
getPaneName(): string;
}

function mapboxGL(options: MapboxGLOptions): MapboxGL;
}

export interface MapboxGLOptions extends L.LayerOptions {
/** Mapbox access token */
accessToken?: string;
/** Mapbox style URL or style object */
style?: string | mapboxgl.StyleSpecification;
/** Update interval in milliseconds (default: 32) */
updateInterval?: number;
/** Padding around the map view (default: 0.1) */
padding?: number;
/** Enable mouse/keyboard events on the mapbox overlay (default: false) */
interactive?: boolean;
/** Custom class name for the canvas element */
className?: string;
/** Minimum zoom level */
minZoom?: number;
/** Maximum zoom level */
maxZoom?: number;
}

export class MapboxGL extends L.Layer {
constructor(options: MapboxGLOptions);
options: MapboxGLOptions;

/** Get the underlying Mapbox GL map instance */
getMapboxMap(): mapboxgl.Map;

/** Get the canvas element */
getCanvas(): HTMLCanvasElement;

/** Get the size of the layer */
getSize(): L.Point;

/** Get the bounds of the layer */
getBounds(): L.LatLngBounds;

/** Get the container element */
getContainer(): HTMLDivElement;

/** Get the pane name */
getPaneName(): string;
}

export function mapboxGL(options: MapboxGLOptions): MapboxGL;

export default mapboxGL;
Loading
Loading