OVERVIEW
Geocode is an API that converts addresses (such as home or business addresses) into geographic coordinates (longitude, latitude) and place_id, or vice versa. This API allows you to convert an address or geographic coordinates into various geographic information such as location, postal code, district, and even business places.
Map fusion Geocode API has two main types:
- Reverse Geocode: Converts geographic coordinates (longitude, latitude) into an address.
- Forward Geocode: Converts an address into geographic coordinates.
Why use Geocode
Geocode is used on websites or mobile apps when you need to convert an address into coordinates to display on a map, or vice versa, converting coordinates into an address to help display content on maps within the Map fusion platform.
You can use the Geocode API when you have a full address, for example, “Shwedagon Pagoda, Yangon, Myanmar“
How Geocode Works
- Forward Geocode: Converts addresses such as “Shwedagon Pagoda, Yangon, Myanmar” into latitude and longitude coordinates. You can use these coordinates to place markers on a map, center the map, or re-locate it in the view frame.
- Reverse Geocode: Converts latitude/longitude or place_id into a readable address. You can use the address for various purposes, including deliveries or pickups.
How to use Geocode
First, you need to register an account and create your Map fusion API key by following the detailed instructions here.
URL: /geocode
Method: GET
CONVERTING COORDINATES TO ADDRESS (FORWARD GEOCODE)
Definition
Forward geocode is the process of converting a specific address into geographic coordinates (latitude and longitude). When you input an address into the system, the Geocode service will search for and return the corresponding coordinates for that address.
How Forward Geocode Works
When you enter an address, the system performs the process of converting the text information into geographic coordinates (latitude, longitude) on the map. This process includes:
- Data Normalization: The system will clean the input data, removing unnecessary words and organizing the address information into a specific structure.
- Database Search: The system compares the normalized address with geographic information available in its database.
- Returning Results: When a matching result is found, the system will return the corresponding geographic coordinates along with additional information such as street names, districts, and so on.
How to integrate map fusion forward geocode
Required parameter
- address – The address for which you want to obtain the coordinates.
Example of request:
'https://api.mapfusion.io/v1/geocode?address=%E1%80%98%E1%80%B1%E1%80%97%E1%80%AD%E1%80%94%E1%80%BA%E1%80%B7%E1%80%99%E1%80%B1%E1%80%AC%E1%80%84%E1%80%BA%E1%80%98%E1%80%AF%E1%80%9B%E1%80%AC%E1%80%B8&api_key={YOUR_API_KEY}'
Parameter | Description | Example |
address | The address for which you want to get the coordinates. | 123 Pyay Road, Sanchaung Township, Yangon, Myanmar |
Example Response:
{ "results": [ { "address_components": [ { "long_name": "ဘေဗိန့်မောင်ဘုရား", "short_name": "ဘေဗိန့်မောင်ဘုရား" }, { "long_name": "Sa Par Kywei", "short_name": "Sa Par Kywei" }, { "long_name": "Myanmar", "short_name": "Myanmar" } ], "formatted_address": "ဘေဗိန့်မောင်ဘုရား, Sa Par Kywei, Myanmar", "geometry": { "location": { "lat": 18.9676133, "lng": 96.3079795 } }, "place_id": "2680688", "reference": "2680688", "types": [], "name": "ဘေဗိန့်မောင်ဘုရား", "address": "Sa Par Kywei, Myanmar" } ], "status": "OK" }
Parameter | Description | Example |
pluscode | Plus Code is a global address code used to precisely identify the location of a place. It can be used to search for a place on map applications or share a location with others. The compound_code represents the full Plus Code, including both the place name and the geographic code. The global_code contains only the global geographic code. |
"plus_code": { "compound_code": "Q5C9+QJ Yangon, Myanmar", "global_code": "7P39Q5C9+QJ" }, |
type | The type of result returned. This array contains a set of categories that identify the type of feature returned in the result.. |
[ “house_number” ] |
reference | A unique identifier that can be used to look up detailed information about a specific location in the Google Maps system |
hvQsDQGiINkZG7D82VhHBzyFnHdPRTtU3 Gg6Xek6b_LPmrVmPWd6XSZgVEHZtrTX/lV8FICmrh ROonRV5FHT4yE==.bm9ybWFs |
formatted_address | A string representing a specific address formatted for readability and understanding.
It includes all necessary details such as house number, street name, district, city, and country. Typically used to display detailed information about a user’s location or address. |
nya Lake, Kabar Aye Pagoda Rd, Mayangone Township, Yangon, Myanmar |
address_components | An array of objects, each representing a component of an address with a full name (long_name) and an abbreviated name (short_name). |
{ "long_name": "Inya Lake", "short_name": "Inya Lake" }, { "long_name": "Kabar Aye Pagoda Rd", "short_name": "Kabar Aye Pagoda Rd" }, ….. |
place_id | A unique identifier used in the Goong Maps API to identify a specific location or object on the map. Each location on Goong Maps has a unique place_id, which helps to identify and retrieve detailed information about that location. |
CRdosr1ubzGqZwEhsJV2xKkCmeNrXbNmYY_ 3IMQoaBxeuLQhZqYnZDX92dmu1_EUr7SNa9oZ cEdGn0w6Ln5J1A==.bm9ybWFs |
geometry | Geometry is a part of the data describing the geographic location of an object, including coordinates (latitude and longitude) and boundaries (returned as an encoded polyline, compressing data to store coordinate sequences efficiently). Boundaries are not always included in the result. |
{ “location”: { “lat”: 21.013672808000024, “lng”: 105.79825090900005 }, “boundary”: “ofg_CuvvdSjBLCf@kBMBg@” |
REVERSE GEOCODE: CONVERT COORDINATES TO ADDRESS
Definition
Reverse geocode is the process of converting coordinates (latitude and longitude) into a specific address or descriptive information about a location, such as street name, city, or country. This service is often used in cases where the coordinates of a certain location are known, but its address or specific details need to be determined.
How Reverse Geocode Works
Unlike forward geocode, reverse geocode performs the reverse operation: converting a pair of geographic coordinates (latitude, longitude) into a specific address. When you provide a location (longitude, latitude), the system searches the geographic database to determine the nearest address to that location. The returned result may include house numbers, street names, cities, and other detailed information.
How to Create a Reverse Geocode Request
Required Parameters
- latlng: The coordinates of the point for which information is needed.
Example Request:
https://api.mapfusion.io/v1/geocode?api_key={YOUR_API_KEY}&latlng=18.973159%2C%2096.310605'
Parameter | Description | Example |
latlng | Coordinates of the point to retrieve information. | 20.981971,105.864323 |
Example Response:
{ "results": [ { "address_components": [ { "long_name": "ဘေဗိန့်မောင်ဘုရား", "short_name": "ဘေဗိန့်မောင်ဘုရား" }, { "long_name": "Sa Par Kywei", "short_name": "Sa Par Kywei" }, { "long_name": "Myanmar", "short_name": "Myanmar" } ], "formatted_address": "ဘေဗိန့်မောင်ဘုရား, Sa Par Kywei, Myanmar", "geometry": { "location": { "lat": 18.9676133, "lng": 96.3079795 } }, "place_id": "2680688", "reference": "2680688", "types": [], "name": "ဘေဗိန့်မောင်ဘုရား", "address": "Sa Par Kywei, Myanmar" } ], "status": "OK" }
Parameter | Description | Example |
status | The status code “ok” means success. If there’s an error, it returns the corresponding error code. | ok |
pluscode | Plus Code is a global address code used to determine the exact location of a place. It can be used to search for a place on map applications or share a location with others. The compound_code is the full Plus Code, including the place name and geographic code; the global_code is the global Plus Code containing only the geographic code. |
{ "compound_code": "+7QHX Bahan, Yangon, Myanmar", "global_code": "7QHX+7QHX" } |
type | The type of result returned. This array contains a set of categories that help define the type of feature returned in the result. |
[ “house_number” ] |
formatted_address | A string that describes a specific address in a formatted, readable form. It includes all necessary details like house number, street name, district/city, province, and country. Typically used to display detailed information about a user’s location or address. | 15th Floor, Sakura Tower, Pyay Road, Bahan, Yangon, Myanmar |
address_components | An array of objects, each representing a component of the address with both the full name (long_name) and the short name (short_name). |
[ { "long_name": "Sakura Tower", "short_name": "Sakura Tower" }, { "long_name": "Pyay Road", "short_name": "Pyay Rd" }, { "long_name": "Bahan", "short_name": "Bahan" }, { "long_name": "Yangon", "short_name": "Yangon" }, { "long_name": "Myanmar", "short_name": "Myanmar" } ] |
place_id | A unique identifier used in Goong Maps APIs to identify a specific location or object on the map. Each place in Goong Maps has a distinct place_id, helping identify and retrieve detailed information about that place. | 7QHX+7QHX-abcdefg12345, yzR5nO7U1ZTyyf+bx6Tw0fY == |
geometry | A part of the data that describes the geographical location of an object, including coordinates (longitude and latitude) and the object’s boundary (if available), which is returned as an encoded polyline to store coordinate strings efficiently. Boundaries are not always available. |
{ "location": { "lat": 16.786443, "lng": 96.159425 }, "boundary":"ofg_Si8qVnxBmM1p@5CB"_CuvvdSjBLCf@kBMBg@” }
|
CONCLUSION
The MapFusion Geocode API is a reliable and efficient solution for processing geographic data with precision. By converting addresses into coordinates (Forward Geocode) and coordinates into addresses (Reverse Geocode), this API enhances map-based services, making it an excellent choice for ride-hailing, delivery, travel, and other location-dependent applications.
Integrating the Geocode API into your system can improve navigation accuracy, enhance user experience, and optimize location-based services. Start using the MapFusion Geocode API today to harness the full power of digital mapping!