TomTom Maps for JavaScript
    Preparing search index...

    Function getPosition

    • Extracts the lng-lat position from various input formats.

      It accepts:

      • Raw coordinate arrays [lng, lat]
      • GeoJSON Point geometries
      • GeoJSON Point Features, including Places with entry points

      With main-when-available, a place's entry point wins over its geometry, as GetPositionEntryPointOption sets out.

      Parameters

      Returns Position | null

      The extracted position as [longitude, latitude], or null if the input is invalid.

      // From Place with entry point
      const place = {
      type: 'Feature',
      geometry: { type: 'Point', coordinates: [4.9, 52.3] },
      properties: {
      entryPoints: [
      { type: 'main', position: [4.901, 52.301] }
      ]
      }
      };
      getPosition(place, { useEntryPoint: 'main-when-available' });
      // Returns: [4.901, 52.301] (entry point instead of geometry)