How to use the @ideditor/country-coder.feature function in @ideditor/country-coder

To help you get started, we’ve selected a few @ideditor/country-coder 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 osmlab / osm-community-index / lib / isValidLocation.js View on Github external
function isValidLocation(location, features) {
  features = features || {};

  if (Array.isArray(location)) {   // a [lon,lat] coordinate pair?
    return !!(
      location.length === 2 && Number.isFinite(location[0]) && Number.isFinite(location[1]) &&
      location[0] >= -180 && location[0] <= 180 && location[1] >= -90 && location[1] <= 90
    );

  } else if (/^\S+\.geojson$/i.test(location)) {   // a .geojson filename?
    let featureId = location.replace('.geojson', '');
    return !!features[featureId];

  } else {    // a country-coder string?
    let ccmatch = CountryCoder.feature(location);
    return !!ccmatch;
  }
}
github ENT8R / NotesReview / js / badges.js View on Github external
export function country(coordinates) {
  const feature = CountryCoder.feature([...coordinates].reverse());
  // Return no badge if the note is not inside a known country
  if (!feature) {
    return;
  }

  const emoji = [];
  for (const codePoint of feature.properties.emojiFlag) {
    emoji.push(codePoint.codePointAt(0).toString(16));
  }
  const url = `https://twemoji.maxcdn.com/v/latest/svg/${emoji.join('-')}.svg`;

  return `<span class="my-1">
            <img src="${url}" class="icon">
          </span>`;
}

@ideditor/country-coder

Convert longitude-latitude pairs to ISO 3166-1 codes quickly and locally

ISC
Latest version published 2 years ago

Package Health Score

48 / 100
Full package analysis