How to use the @here/harp-features-datasource.FeaturesDataSource function in @here/harp-features-datasource

To help you get started, we’ve selected a few @here/harp-features-datasource 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 heremaps / harp.gl / @here / harp-examples / src / datasource_features_lines-and-points.ts View on Github external
* ```typescript
 * [[include:harp_demo_features_linespoints_3.ts]]
 * ```
 *
 * Note how the [[StyleSet]] of this example creates the text paths out of the line features. Also,
 * we duplicate the line styles, one being a dashed line and the other a solid line, to have this
 * specific look for the ridges and trenches. The point style is also duplicated, so that a bigger
 * point is rendered below the first one, and creates an outline effect.
 */
export namespace LinesPointsFeaturesExample {
    // snippet:harp_demo_features_linespoints_0.ts
    const map = createBaseMap();
    // end:harp_demo_features_linespoints_0.ts

    // snippet:harp_demo_features_linespoints_3.ts
    const featuresDataSource = new FeaturesDataSource();
    map.addDataSource(featuresDataSource).then(() => {
        const features = getFeatures(faults);
        const styleSet = getStyleSet();
        featuresDataSource.add(...features).setStyleSet(styleSet);
    });
    // end:harp_demo_features_linespoints_3.ts

    function getFeatures(features: {
        [key: string]: { [key: string]: number[][] };
    }): MapViewFeature[] {
        const featuresList: MapViewFeature[] = [];
        for (const type of Object.keys(features)) {
            for (const featureName of Object.keys(features[type])) {
                const name = featureName.indexOf("unknown") === -1 ? featureName : undefined;
                // snippet:harp_demo_features_linespoints_1.ts
                const feature = new MapViewLineFeature(features[type][featureName], { name, type });
github heremaps / harp.gl / @here / harp-examples / src / features.ts View on Github external
*
 * Then we create a [[MapViewFeature]] and add it to a [[FeaturesDataSource]] with a custom
 * [[StyleSet]].
 * ```typescript
 * [[include:harp_simple_features_example_1.ts]]
 * ```
 */
export namespace SimpleFeaturesExample {
    // snippet:harp_simple_features_example_0.ts
    const map = createBaseMap();
    // end:harp_simple_features_example_0.ts

    // snippet:harp_simple_features_example_1.ts
    // We need to replicate the first point in the last coordinate to close the polygon.
    const polygon = new MapViewPolygonFeature([[[10, 50], [10, 30], [5, 30], [5, 50], [10, 50]]]);
    const featuresDataSource = new FeaturesDataSource();
    map.addDataSource(featuresDataSource).then(() => {
        featuresDataSource.add(polygon).setStyleSet([
            {
                technique: "fill",
                when: "$geometryType == 'polygon'",
                renderOrder: 10000,
                attr: {
                    color: "#ff0000"
                }
            }
        ]);
    });
    // end:harp_simple_features_example_1.ts

    function createBaseMap(): MapView {
        document.body.innerHTML += getExampleHTML();
github heremaps / harp.gl / @here / harp-examples / src / datasource_features_polygons.ts View on Github external
k++;
            }
            if (stateGroup.indexOf("germany") > -1) {
                age = steps.length;
            }

            // snippet:harp_demo_features_polygons_2.ts
            for (const country of stateGroup) {
                const feature = new MapViewMultiPolygonFeature(COUNTRIES[country], {
                    name: country,
                    joiningDate: getJoiningDate(j),
                    height: 25000 + age * 25000
                });
                features.push(feature);
            }
            const featuresDataSource = new FeaturesDataSource({
                name: `member-states-${j}`,
                styleSetName: "geojson",
                features,
                maxGeometryHeight: 300000
            });
            const addPromise = map.addDataSource(featuresDataSource);
            addPromises.push(addPromise);
            datasources.push(featuresDataSource);
            // end:harp_demo_features_polygons_2.ts
        }
        return datasources;
    }
github heremaps / harp.gl / @here / harp-examples / src / datasource_features_lines-and-points.ts View on Github external
description: "South pole",
                    when: ["==", ["get", "kind"], "south_pole"],
                    technique: "fill",
                    attr: {
                        color: ["ref", "southPoleColor"]
                    },
                    renderOrder: 5
                }
            ]
        }
    };
    const map = createBaseMap(customizedTheme);
    // end:harp_demo_features_linespoints_0.ts

    // snippet:harp_demo_features_linespoints_3.ts
    const featuresDataSource = new FeaturesDataSource({
        name: "geojson",
        styleSetName: "myStyleSet",
        features: getFeatures(faults)
    });
    map.addDataSource(featuresDataSource);
    // end:harp_demo_features_linespoints_3.ts

    function getFeatures(features: {
        [key: string]: { [key: string]: number[][] };
    }): MapViewFeature[] {
        const featuresList: MapViewFeature[] = [];
        for (const type of Object.keys(features)) {
            for (const featureName of Object.keys(features[type])) {
                const name = featureName.indexOf("unknown") === -1 ? featureName : undefined;
                // snippet:harp_demo_features_linespoints_1.ts
                const feature = new MapViewLineFeature(features[type][featureName], { name, type });
github heremaps / harp.gl / @here / harp-examples / src / geojson-viewer.ts View on Github external
import { APIFormat, OmvDataSource } from "@here/harp-omv-datasource";
import { accessToken, copyrightInfo } from "../config";

/**
 * In this example we avail ourselves of the [[FeaturesDataSource]] and its `setFromGeoJson` method
 * to read GeoJSON from a file or from a textarea in the page. A default style is applied for all
 * possible geometry types.
 */
export namespace GeoJsonExample {
    const editorWidth = "550px";
    const map = createBaseMap();

    setUpFilePicker();
    setUpEditor();

    const featuresDataSource = new FeaturesDataSource();
    map.addDataSource(featuresDataSource).then(() => {
        featuresDataSource.setStyleSet(getStyleSet());
    });

    function setUpEditor() {
        const editorInput = document.querySelector("#editor textarea") as HTMLTextAreaElement;
        editorInput.placeholder = `{
    type: "FeatureCollection",
    features:[

    ]
}`;
        const updateButton = document.querySelector("#editor button") as HTMLButtonElement;
        updateButton.addEventListener("click", () => {
            const geojson = JSON.parse(
                (document.querySelector("#editor textarea") as HTMLTextAreaElement).value

@here/harp-features-datasource

Provides support for custom features

Apache-2.0
Latest version published 3 years ago

Package Health Score

51 / 100
Full package analysis

Similar packages