Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To use JavaScript records with HERE, convert each record into a GeoJSON Feature, put its coordinates in [longitude, latitude] order, and collect the features in a FeatureCollection. You can then parse that object for browser rendering or publish it through a HERE catalog workflow, depending on where you want the data to live.

Shape the source records as GeoJSON

GeoJSON is a JSON-based format for geographic data. A typical export containing several locations is a FeatureCollection: its features array holds one Feature per record. Each feature has a geometry for its location or shape and can have a properties object for ordinary application data. A feature can also carry an ID.

For a point, coordinates are an array of longitude followed by latitude. Do not reverse them. For example, a source row with longitude: -73.9857 and latitude: 40.7484 becomes coordinates: [-73.9857, 40.7484]. GeoJSON positions may include elevation as a third value, but this example uses two-dimensional points. See the GeoJSON specification for the format rules.

Convert records into a FeatureCollection

The function below expects each record to contain an ID and numeric longitude and latitude. It converts coordinate inputs to numbers, rejects invalid or out-of-range positions, retains selected attributes in properties, and returns a collection ready to serialize.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
function recordsToGeoJSON(records) {
  const features = records.map((row) => {
    const lon = Number(row.longitude);
    const lat = Number(row.latitude);

    if (!Number.isFinite(lon) || !Number.isFinite(lat) ||
        lon < -180 || lon > 180 || lat < -90 || lat > 90) {
      throw new Error(`Invalid coordinates for record ${row.id}`);
    }

    return {
      type: "Feature",
      id: row.id,
      properties: {
        name: row.name ?? null,
        category: row.category ?? null
      },
      geometry: {
        type: "Point",
        coordinates: [lon, lat]
      }
    };
  });

  return {
    type: "FeatureCollection",
    features
  };
}

const geojson = recordsToGeoJSON(rows);
const body = JSON.stringify(geojson);

body is a JSON string suitable for sending as a request body or saving as a file. Keep non-spatial fields inside properties, unless the receiving HERE product documents a particular extension. Preserve source IDs when the destination workflow supports them.

Match coordinate nesting to the geometry

The geometry type determines how deeply coordinates are nested. A Point uses one position; a LineString uses an array of positions; and a Polygon uses an array of linear rings, with the first ring representing the exterior boundary and subsequent rings representing holes. Multi-geometries add another level to group their component geometries.

HERE Workspace documentation lists Point, MultiPoint, LineString, MultiLineString, Polygon, and MultiPolygon as GeoJSON geometry types supported for visualization. See HERE Workspace: Visualize data for its workflow and format guidance.

Render the GeoJSON in a HERE JavaScript map

For browser-side rendering, HERE Maps API for JavaScript provides H.data.geojson. Its reader can parse a GeoJSON data object and provide a layer to add to a map. The map and HERE API setup must already be initialized.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const reader = new H.data.geojson.Reader();
reader.parseData(geojson);
map.addLayer(reader.getLayer());

The input here is the JavaScript object returned by recordsToGeoJSON, not the serialized body string. The reader also supports parsing from a URL; consult the HERE Maps API for JavaScript GeoJSON guide for the documented reader behavior and API details.

Publish data through a HERE catalog workflow

Rendering a data object in a browser and publishing hosted data are separate tasks. For a catalog-backed workflow, HERE’s Data API process involves credentials and authorization, identifying or creating a target catalog, and publishing data to it. Workspace can visualize a local GeoJSON file or connect to a catalog that stores GeoJSON. Follow the applicable product documentation for the account setup, identifiers, request details, and publishing method rather than treating the browser reader as an upload mechanism.

Start with HERE Data API documentation for the catalog and data publishing workflow. Verify that you have authorization for the target catalog and the required catalog and layer identifiers before sending data; exact publishing steps depend on the HERE service and tooling you use.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Apply styling for the receiving HERE product

Style instructions are not universal across HERE products. The HERE Map Image API tutorial demonstrates FeatureCollection styling through feature properties: point features can use marker and size, while line features can use color, width, outline-color, and outline-width. Check the documentation for the specific product receiving the data before adding those properties; do not assume a style key or accepted value will work identically in the JavaScript map API, Workspace, and Map Image API.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

See the HERE Map Image API styling tutorial for the example it documents.

Troubleshoot a GeoJSON import or rendering problem

  • Features appear in the wrong place: check that every coordinate position uses longitude, latitude order and that the values fall within longitude -180 to 180 and latitude -90 to 90.
  • The parser rejects a feature: confirm each feature has a valid geometry, the geometry type matches its coordinate nesting, and numeric values are finite. Keep application fields in properties.
  • The payload is invalid JSON: serialize the object with JSON.stringify. Do not put JavaScript comments or trailing commas in the JSON payload.
  • A hosted upload fails: check authorization, catalog and layer identifiers, the request content type, and the upload response before changing valid geometry.
  • You need to isolate a rendering issue: test a minimal one-point FeatureCollection first. Add other geometry types, properties, and product-specific styling incrementally.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.