providers/google.js
function toGeoJSON(json, options = Options) {
  const short = options.short || Options.short
  const collection = helpers.featureCollection([])
  json.results.map(result => {
    // Get Geometries
    const point = parsePoint(result)
    const bbox = parseBBox(result)

    // Calculate Confidence score
    const location_type = result.geometry.location_type
    let confidence = confidenceScore(bbox)
    if (location_type === 'ROOFTOP') { confidence = 10 }

    // GeoJSON Point properties
    const properties = {
      confidence,
      location_type,
      formatted_address: result.formatted_address,
      place_id: result.place_id,
      types: result.types,
    }

    // Google Specific Properties
    const components = parseAddressComponents(result.address_components, short)
    Object.keys(components).forEach(key => properties[key] = components[key])

    // Store Point to GeoJSON feature collection
    if (point) {
      point.bbox = bbox
      point.properties = properties
      collection.features.push(point)
    }
  })
  return collection
}
function toGeoJSON(json, options = Options) {
  const short = options.short || Options.short
  const collection = helpers.featureCollection([])
  json.results.map(result => {
    // Get Geometries
    const point = parsePoint(result)
    const bbox = parseBBox(result)

    // Calculate Confidence score
    const location_type = result.geometry.location_type
    let confidence = confidenceScore(bbox)
    if (location_type === 'ROOFTOP') { confidence = 10 }

    // GeoJSON Point properties
    const properties = {
      confidence,
      location_type,
      formatted_address: result.formatted_address,
      place_id: result.place_id,
      types: result.types,
    }

    // Google Specific Properties
    const components = parseAddressComponents(result.address_components, short)
    Object.keys(components).forEach(key => properties[key] = components[key])

    // Store Point to GeoJSON feature collection
    if (point) {
      point.bbox = bbox
      point.properties = properties
      collection.features.push(point)
    }
  })
  return collection
}
function toGeoJSON ( json , options = Options ) { const short = options . short || Options . short const collection = helpers . featureCollection ( [ ] ) json . results . map ( result => { // Get Geometries const point = parsePoint ( result ) const bbox = parseBBox ( result ) // Calculate Confidence score const location_type = result . geometry . location_type let confidence = confidenceScore ( bbox ) if ( location_type === 'ROOFTOP' ) { confidence = 10 } // GeoJSON Point properties const properties = { confidence , location_type , formatted_address : result . formatted_address , place_id : result . place_id , types : result . types , } // Google Specific Properties const components = parseAddressComponents ( result . address_components , short ) Object . keys ( components ) . forEach ( key => properties [ key ] = components [ key ] ) // Store Point to GeoJSON feature collection if ( point ) { point . bbox = bbox point . properties = properties collection . features . push ( point ) } } ) return collection }
Convert Google results into GeoJSON
Convert Google results into GeoJSON