{"id":19188924,"url":"https://github.com/kelvins/geocoder","last_synced_at":"2025-05-08T02:47:45.425Z","repository":{"id":57483637,"uuid":"90435531","full_name":"kelvins/geocoder","owner":"kelvins","description":" :earth_americas: GoLang package that provides an easy way to use the Google Geocoding API","archived":false,"fork":false,"pushed_at":"2023-11-12T13:08:12.000Z","size":34,"stargazers_count":54,"open_issues_count":2,"forks_count":26,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-20T06:35:02.637Z","etag":null,"topics":["api","geocoder","geocoding","geocoding-api","go","golang","google","google-api"],"latest_commit_sha":null,"homepage":"https://developers.google.com/maps/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kelvins.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-05-06T03:48:16.000Z","updated_at":"2025-02-06T15:14:00.000Z","dependencies_parsed_at":"2023-11-12T14:24:07.433Z","dependency_job_id":"1cfc4eec-e194-436c-bb95-b0a8fd2da6e7","html_url":"https://github.com/kelvins/geocoder","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kelvins%2Fgeocoder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kelvins%2Fgeocoder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kelvins%2Fgeocoder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kelvins%2Fgeocoder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kelvins","download_url":"https://codeload.github.com/kelvins/geocoder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252989944,"owners_count":21836665,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","geocoder","geocoding","geocoding-api","go","golang","google","google-api"],"created_at":"2024-11-09T11:26:43.434Z","updated_at":"2025-05-08T02:47:45.396Z","avatar_url":"https://github.com/kelvins.png","language":"Go","readme":"# Geocoder\n\n[![Build Status](https://travis-ci.org/kelvins/geocoder.svg?branch=master)](https://travis-ci.org/kelvins/geocoder)\n[![Coverage Status](https://coveralls.io/repos/github/kelvins/geocoder/badge.svg?branch=master)](https://coveralls.io/github/kelvins/geocoder?branch=master)\n[![Go Report Card](https://goreportcard.com/badge/github.com/kelvins/geocoder)](https://goreportcard.com/report/github.com/kelvins/geocoder)\n\nGoLang package that provides an easy way to use the Google Geocoding API.\n\nSee more information about the **Google Geocoding API** at the following link: https://developers.google.com/maps/documentation/geocoding/start\n\nYou can use go get:\n\n```\ngo get github.com/kelvins/geocoder\n```\n\n## Usage\n\nExample of usage:\n\n``` go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/kelvins/geocoder\"\n)\n\nfunc main() {\n\t// This example should work without need of an API Key,\n\t// but when you will use the API in your project you need\n\t// to set your API KEY as explained here:\n\t// https://developers.google.com/maps/documentation/geocoding/get-api-key\n\t// geocoder.ApiKey = \"YOUR_API_KEY\"\n\n\t// See all Address fields in the documentation\n\taddress := geocoder.Address{\n\t\tStreet:  \"Central Park West\",\n\t\tNumber:  115,\n\t\tCity:    \"New York\",\n\t\tState:   \"New York\",\n\t\tCountry: \"United States\",\n\t}\n\n\t// Convert address to location (latitude, longitude)\n\tlocation, err := geocoder.Geocoding(address)\n\n\tif err != nil {\n\t\tfmt.Println(\"Could not get the location: \", err)\n\t} else {\n\t\tfmt.Println(\"Latitude: \", location.Latitude)\n\t\tfmt.Println(\"Longitude: \", location.Longitude)\n\t}\n\n\t// Set the latitude and longitude\n\tlocation = geocoder.Location{\n\t\tLatitude:  40.775807,\n\t\tLongitude: -73.97632,\n\t}\n\n\t// Convert location (latitude, longitude) to a slice of addresses\n\taddresses, err := geocoder.GeocodingReverse(location)\n\n\tif err != nil {\n\t\tfmt.Println(\"Could not get the addresses: \", err)\n\t} else {\n\t\t// Usually, the first address returned from the API\n\t\t// is more detailed, so let's work with it\n\t\taddress = addresses[0]\n\n\t\t// Print the address formatted by the geocoder package\n\t\tfmt.Println(address.FormatAddress())\n\t\t// Print the formatted address from the API\n\t\tfmt.Println(address.FormattedAddress)\n\t\t// Print the type of the address\n\t\tfmt.Println(address.Types)\n\t}\n}\n```\n\nResults:\n\n```\nLatitude:  40.7758882\nLongitude:  -73.9764703\n115, Central Park West, Manhattan, 10023, New York, New York County, New York, United States\n115 Central Park West, New York, NY 10023, USA\nstreet_address\n```\n\n## General\n\n#### Geocoder\n\n\u003e [Geocoder (noun): A piece of software or a (web) service that implements a geocoding process i.e. a set of interrelated components in the form of operations, algorithms, and data sources that work together to produce a spatial representation for descriptive locational references.](https://en.wikipedia.org/wiki/Geocoding)\n\n#### Geocoding\n\n\u003e [Geocoding is the process of converting addresses (like a street address) into geographic coordinates (like latitude and longitude), which you can use to place markers on a map, or position the map.](https://developers.google.com/maps/documentation/geocoding/start)\n\n#### Reverse Geocoding\n\n\u003e [Reverse geocoding is the process of converting geographic coordinates into a human-readable address. The Google Maps Geocoding API's reverse geocoding service also lets you find the address for a given place ID.](https://developers.google.com/maps/documentation/geocoding/start)\n\n#### Application Programming Interface (API)\n\n\u003e [Application Programming Interface (API) is a set of subroutine definitions, protocols, and tools for building application software. In general terms, it is a set of clearly defined methods of communication between various software components. A good API makes it easier to develop a computer program by providing all the building blocks, which are then put together by the programmer.](https://en.wikipedia.org/wiki/Application_programming_interface)\n\n## Documentation\n\nYou can access the full documentation here: [![GoDoc](https://godoc.org/github.com/kelvins/geocoder?status.svg)](https://godoc.org/github.com/kelvins/geocoder)\n\n## License\n\nThis project was created under the **MIT license**. You can read the license here: [![License: MIT](https://img.shields.io/badge/License-MIT-brightgreen.svg)](LICENSE)\n\nFeel free to contribute by commenting, suggesting, creating issues or sending pull requests. Any help is welcome.\n\n## Contributing\n\n1. Create an issue (optional)\n2. Fork the repo\n3. Make your changes\n4. Commit your changes (`git commit -am 'Some cool feature'`)\n5. Push to the branch (`git push origin master`)\n6. Create a new Pull Request\n\n## Using Goroutines\n\nWith a little more effort you can use **goroutines** with **channels**:\n\n``` go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/kelvins/geocoder\"\n)\n\n// Use the channels system to call the Geocoding function\nfunc geocodingChannel(address geocoder.Address, locationChan chan geocoder.Location, errChan chan error) {\n\tfmt.Println(\"Entering geocodingChannel function...\")\n\tdefer fmt.Println(\"Exiting geocodingChannel function...\")\n\n\tdefer close(locationChan)\n\tdefer close(errChan)\n\n\tlocation, err := geocoder.Geocoding(address)\n\n\tlocationChan \u003c- location\n\terrChan \u003c- err\n}\n\n// Use the channels system to call the GeocodingReverse function\nfunc geocodingReverseChannel(location geocoder.Location, addressesChan chan []geocoder.Address, errChan chan error) {\n\tfmt.Println(\"Entering geocodingReverseChannel function...\")\n\tdefer fmt.Println(\"Exiting geocodingReverseChannel function...\")\n\n\tdefer close(addressesChan)\n\tdefer close(errChan)\n\n\taddresses, err := geocoder.GeocodingReverse(location)\n\n\taddressesChan \u003c- addresses\n\terrChan \u003c- err\n}\n\nfunc main() {\n\t// See all Address fields in the documentation\n\taddress := geocoder.Address{\n\t\tStreet:  \"Central Park West\",\n\t\tNumber:  115,\n\t\tCity:    \"New York\",\n\t\tState:   \"New York\",\n\t\tCountry: \"United States\",\n\t}\n\n\t// Make the channels\n\tlocationChan := make(chan geocoder.Location)\n\terrChan := make(chan error)\n\n\t// Call the go routine\n\tgo geocodingChannel(address, locationChan, errChan)\n\n\t// Do whatever you need to do\n\tfor index := 0; index \u003c 5; index++ {\n\t\tfmt.Println(index)\n\t\ttime.Sleep(50 * time.Millisecond)\n\t}\n\n\t// Get the results\n\tlocation := \u003c-locationChan\n\terr := \u003c-errChan\n\n\t// Check if the results are valid\n\tif err != nil {\n\t\tfmt.Println(\"Could not get the location: \", err)\n\t} else {\n\t\tfmt.Println(\"Latitude: \", location.Latitude)\n\t\tfmt.Println(\"Longitude: \", location.Longitude)\n\t}\n\n\t// Set the latitude and longitude\n\tlocation = geocoder.Location{\n\t\tLatitude:  40.775807,\n\t\tLongitude: -73.97632,\n\t}\n\n\t// Make the channels\n\taddressesChan := make(chan []geocoder.Address)\n\terrChan = make(chan error)\n\n\t// Call the go routine\n\tgo geocodingReverseChannel(location, addressesChan, errChan)\n\n\t// Do whatever you need to do\n\tfor index := 0; index \u003c 5; index++ {\n\t\tfmt.Println(index)\n\t\ttime.Sleep(50 * time.Millisecond)\n\t}\n\n\t// Get the results\n\taddresses := \u003c-addressesChan\n\terr = \u003c-errChan\n\n\t// Check if the results are valid\n\tif err != nil {\n\t\tfmt.Println(\"Could not get the addresses: \", err)\n\t} else {\n\t\tfmt.Println(addresses[0].FormattedAddress)\n\t}\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkelvins%2Fgeocoder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkelvins%2Fgeocoder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkelvins%2Fgeocoder/lists"}