Skip to content

Commit

Permalink
Adjust and add a few layer types (#179)
Browse files Browse the repository at this point in the history
* adjust layer return, add a few public layer class props, and export layer options
  • Loading branch information
jwasilgeo authored Jan 5, 2025
1 parent da47e14 commit dd6fff5
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/frontends/leaflet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ const reflect = (promise: Promise<Status>) => {
type DoneCallback = (error?: Error, tile?: HTMLElement) => void;
type KeyedHtmlCanvasElement = HTMLCanvasElement & { key: string };

interface LeafletLayerOptions {
bounds?: number[][];
export interface LeafletLayerOptions extends L.GridLayerOptions {
bounds?: L.LatLngBoundsExpression;
attribution?: string;
debug?: string;
lang?: string;
Expand All @@ -61,8 +61,12 @@ interface LeafletLayerOptions {
backgroundColor?: string;
}

const leafletLayer = (options: LeafletLayerOptions = {}): unknown => {
const leafletLayer = (options: LeafletLayerOptions = {}) => {
class LeafletLayer extends L.GridLayer {
public paintRules: PaintRule[];
public labelRules: LabelRule[];
public backgroundColor?: string;

constructor(options: LeafletLayerOptions = {}) {
if (options.noWrap && !options.bounds)
options.bounds = [
Expand Down Expand Up @@ -273,7 +277,7 @@ const leafletLayer = (options: LeafletLayerOptions = {}): unknown => {

// a primitive way to check the features at a certain point.
// it does not support hover states, cursor changes, or changing the style of the selected feature,
// so is only appropriate for debuggging or very basic use cases.
// so is only appropriate for debugging or very basic use cases.
// those features are outside of the scope of this library:
// for fully pickable, interactive features, use MapLibre GL JS instead.
public queryTileFeaturesDebug(
Expand Down

0 comments on commit dd6fff5

Please sign in to comment.