
Security News
Astral Launches pyx: A Python-Native Package Registry
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
A simple Ruby gem for Google Maps Geocoding API. This gem return a Ruby Hash object of the result.
Add this line to your application's Gemfile:
gem 'gmaps_geocoding'
And then execute:
bundle
Or install it yourself as:
gem install gmaps_geocoding
See Google Maps Geocoding service documentation for options parameters and result handling.
All options could be overriden with corresponding environment variable:
GOOGLE_MAPS_GEOCODING_URL
: HTTP endpoint to the Google geocoding service by default is set to https://maps.googleapis.com/maps/api/geocode.GOOGLE_MAPS_GEOCODING_OUTPUT
: By default is set to json
GOOGLE_MAPS_GEOCODING_KEY
GOOGLE_MAPS_GEOCODING_ADDRESS
GOOGLE_MAPS_GEOCODING_LATLNG
GOOGLE_MAPS_GEOCODING_COMPONENTS
GOOGLE_MAPS_GEOCODING_SENSOR
: By default is set to false
GOOGLE_MAPS_GEOCODING_BOUNDS
GOOGLE_MAPS_GEOCODING_LANGUAGE
GOOGLE_MAPS_GEOCODING_REGION
GOOGLE_MAPS_GEOCODING_PLACE_ID
GOOGLE_MAPS_GEOCODING_RESULT_TYPE
GOOGLE_MAPS_GEOCODING_LOCATION_TYPE
opts = {address: 'Tour Eiffel, Paris, IDF, France'}
api = GmapsGeocoding::Api.new(opts)
data = api.location
loc = api.finest_latlng(data['results']) if data.include?('status') && data['status'].eql?('OK')
Return a location array
loc[0] is the longitude float value
loc[1] is the latitude float value
finest_latlng
retrieve the best address in this order:
# json output example
opts = {address: 'Tour Eiffel, Paris, IDF, France', output: 'json'}
api = GmapsGeocoding::Api.new(opts)
result = api.location
# xml output example
opts = {address: 'Tour Eiffel, Paris, IDF, France', output: 'xml'}
api = GmapsGeocoding::Api.new(opts)
result = api.location
Ruby Hash object from json output
{
"results"=>[{
"address_components"=>[
{"long_name"=>"Eiffel Tower", "short_name"=>"Eiffel Tower", "types"=>["point_of_interest", "establishment"]},
{"long_name"=>"5", "short_name"=>"5", "types"=>["street_number"]},
{"long_name"=>"Avenue Anatole France", "short_name"=>"Avenue Anatole France", "types"=>["route"]},
{"long_name"=>"Paris", "short_name"=>"Paris", "types"=>["locality", "political"]},
{"long_name"=>"Paris", "short_name"=>"75", "types"=>["administrative_area_level_2", "political"]},
{"long_name"=>"Île-de-France", "short_name"=>"IDF", "types"=>["administrative_area_level_1", "political"]},
{"long_name"=>"France", "short_name"=>"FR", "types"=>["country", "political"]},
{"long_name"=>"75007", "short_name"=>"75007", "types"=>["postal_code"]}
],
"formatted_address"=>"Eiffel Tower, Champ de Mars, 5 Avenue Anatole France, 75007 Paris, France",
"geometry"=>{
"location"=>{"lat"=>48.85837009999999, "lng"=>2.2944813},
"location_type"=>"APPROXIMATE",
"viewport"=>{
"northeast"=>{"lat"=>48.8597190802915, "lng"=>2.295830280291502},
"southwest"=>{"lat"=>48.8570211197085, "lng"=>2.293132319708498}
}
},
"place_id"=>"ChIJLU7jZClu5kcR4PcOOO6p3I0",
"types"=>["premise", "point_of_interest", "establishment"]
}],
"status"=>"OK"
}
Ruby Hash object from xml output
{
"status"=>"OK",
"result"=>{
"type"=>["premise", "point_of_interest", "establishment"],
"formatted_address"=>"Eiffel Tower, Champ de Mars, 5 Avenue Anatole France, 75007 Paris, France",
"address_component"=>[
{"long_name"=>"Eiffel Tower", "short_name"=>"Eiffel Tower", "type"=>["point_of_interest", "establishment"]},
{"long_name"=>"5", "short_name"=>"5", "type"=>"street_number"},
{"long_name"=>"Avenue Anatole France", "short_name"=>"Avenue Anatole France", "type"=>"route"},
{"long_name"=>"Paris", "short_name"=>"Paris", "type"=>["locality", "political"]},
{"long_name"=>"Paris", "short_name"=>"75", "type"=>["administrative_area_level_2", "political"]},
{"long_name"=>"Île-de-France", "short_name"=>"IDF", "type"=>["administrative_area_level_1", "political"]},
{"long_name"=>"France", "short_name"=>"FR", "type"=>["country", "political"]},
{"long_name"=>"75007", "short_name"=>"75007", "type"=>"postal_code"}
],
"geometry"=>{
"location"=>{"lat"=>"48.8583701", "lng"=>"2.2944813"},
"location_type"=>"APPROXIMATE",
"viewport"=>{"southwest"=>{"lat"=>"48.8570211", "lng"=>"2.2931323"}, "northeast"=>{"lat"=>"48.8597191", "lng"=>"2.2958303"}}
},
"place_id"=>"ChIJLU7jZClu5kcR4PcOOO6p3I0"
}
}
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)Copyright (c) 2013 Christian Kakesa. See LICENSE.txt for more details.
FAQs
Unknown package
We found that gmaps_geocoding demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.