How to use @hpcc-js/leaflet-shim - 10 common examples

To help you get started, we’ve selected a few @hpcc-js/leaflet-shim examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hpcc-systems / Visualization / packages / map / src / leaflet / MapBox.ts View on Github external
layerEnter(map: Map) {
        super.layerEnter(map);
        //  Default key should be in sync with packages/map-deck/src/Common.ts
        if (!window.__hpcc_mapbox_apikey) {
            console.warn("__hpcc_mapbox_apikey does not contain a valid API key, reverting to developers key (expect limited performance)");
        }
        const hpcc_mapbox_apikey = window.__hpcc_mapbox_apikey || "pk.eyJ1IjoibGVzY2htb28iLCJhIjoiY2psY2FqY3l3MDhqNDN3cDl1MzFmZnkwcCJ9.HRoFwmz1j80gyz18ruggqw";
        this.add(new LeafletTileLayer(`https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=${hpcc_mapbox_apikey}`, {
            attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
            maxZoom: 18,
            id: "mapbox.streets",
            accessToken: hpcc_mapbox_apikey
        } as any));
    }
}
github hpcc-systems / Visualization / packages / map / src / leaflet / FeatureLayer.ts View on Github external
FeatureLayer.prototype.mixin(Utility.SimpleSelectionMixin);
FeatureLayer.prototype.publishReset(["layers"]);

//  ---------------------------------------------------------------------------
export class ClusterLayer extends FeatureLayer {

    constructor(cluster = true) {
        super(cluster);
    }
}
ClusterLayer.prototype._class += " map_ClusterLayer";

//  ---------------------------------------------------------------------------
export class D3SurfaceLayer extends FeatureLayer {

    protected _lfd3 = new D3SvgOverlay()
        .drawCallback((selection, projection) => this.layerUpdate(undefined, projection));

    hasBounds(): boolean {
        return true;
    }

    getBounds() {
        return this._lfd3.getBounds();
    }

    layerEnter(map: Map) {
        super.layerEnter(map);
        this.add(this._lfd3);
    }

    layerUpdate(map: Map, projection?) {
github hpcc-systems / Visualization / packages / map / src / leaflet / TileLayer.ts View on Github external
init(): Promise;
    hasBounds(): boolean;
    getBounds(): LatLngBounds;

    layerEnter(map: Map);
    layerUpdate(map: Map);
    layerExit(map: Map);

    zoomEnd(e);
    moveEnd(e);
    viewReset(e);
}

export class TileLayer extends Widget implements ILayer {
    private _layer = new FeatureGroup();
    protected _crs: any = CRS.EPSG3857;

    constructor(cluster = false) {
        super();
        (this._layer as any).__hpcc_layer = this;
    }

    crs() {
        return this._crs;
    }

    attribution(): string {
        return "";
    }

    clear() {
        this._layer.clearLayers();
github hpcc-systems / Visualization / packages / map / src / leaflet / AlbersPR.ts View on Github external
getBounds() {
        return new LatLngBounds([20, -123], [49, -64]);
    }
}
github hpcc-systems / Visualization / packages / map / src / leaflet / HeatLayer.ts View on Github external
const data = this.data().filter(row => !this.omitNullLatLong() || (!!row[latIdx] && !!row[longIdx])).map(row => {
            if (!bounds) {
                bounds = new LatLngBounds([row[latIdx], row[longIdx]]);
            } else {
                bounds.extend([row[latIdx], row[longIdx]]);
            }
            return [row[latIdx], row[longIdx], this.weightColumn_exists() ? row[weightIdx] : 0.5];
        });
        const heat = new LHeatLayer(data, {
github hpcc-systems / Visualization / packages / map / src / leaflet / US.ts View on Github external
getBounds() {
        const retVal = super.getBounds();
        return new LatLngBounds([retVal.getNorth(), retVal.getWest()], [17.755278, -64.565]);
    }
github hpcc-systems / Visualization / packages / map / src / leaflet / ClusterCircles.ts View on Github external
protected createIcon(childCount: number, backColor: string, format: (_: any) =&gt; any) {
        const borderColor = d3Hsl(backColor);
        borderColor.opacity = 0.5;
        return new DivIcon({
            className: "cluster-circle",
            iconSize: new Point(40, 40),
            html: `<div style="opacity:${this.opacity()};background-color:${borderColor.toString()}"><div style="background-color:${backColor}"><span style="color:${Palette.textColor(backColor)}">${format(childCount)}</span></div></div>`
        });
    }
github hpcc-systems / Visualization / packages / map / src / leaflet / AlbersPR.ts View on Github external
project(latLng) {
        let point = projAlbersUsaPr([latLng.lng, latLng.lat]);
        if (!point) {
            point = projAlbers([latLng.lng, latLng.lat]);
        }
        return new Point(point[0], point[1]);
    },
    unproject(point) {
github hpcc-systems / Visualization / packages / map / src / leaflet / ClusterCircles.ts View on Github external
protected createIcon(childCount: number, backColor: string, format: (_: any) =&gt; any) {
        const borderColor = d3Hsl(backColor);
        borderColor.opacity = 0.5;
        return new DivIcon({
            className: "cluster-circle",
            iconSize: new Point(40, 40),
            html: `<div style="opacity:${this.opacity()};background-color:${borderColor.toString()}"><div style="background-color:${backColor}"><span style="color:${Palette.textColor(backColor)}">${format(childCount)}</span></div></div>`
        });
    }
github hpcc-systems / Visualization / packages / map / src / leaflet / AlbersPR.ts View on Github external
unproject(point) {
        if (!isNaN(point.x) && !isNaN(point.y)) {
            const latLng = projAlbers.invert([point.x, point.y]);
            return new LatLng(latLng[1], latLng[0]);
        } else {
            return new LatLng(0, 0);
        }
    }
};