GoogleMaps
Geoencoding API
Geocoding is the process of converting addresses into geographic coordinates, which you can use to place markers on a map, or position the map. Reverse geocoding is the process of converting geographic coordinates into a human-readable address.
Geocoding API Request Format
https://maps.googleapis.com/maps/api/geocode/outputFormat?parameters
Geocoding Responsees
https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,
+Mountain+View,+CA&key=YOUR_API_KEY
https://maps.googleapis.com/maps/api/geocode/xml?address=1600+Amphitheatre+Parkway,
+Mountain+View,+CA&key=YOUR_API_KEY
We can get the appropriate url with the following functions.
/**
* Google Search URL
* @param query
* @param language ("en", "ko", ...)
* @param google_api_key
* @return
*/
public static String getGoogleMapSearchUrl(String query, String language, String google_api_key)
{
String encoding = null;
try {
encoding = URLEncoder.encode(query, "utf-8");
} catch (UnsupportedEncodingException e1) {
encoding = query;
}
// Building the url to the web service
String url = "https://maps.googleapis.com/maps/api/geocode/json?"
+ "language=" + language
+ "&address=" + encoding
+ "&key=" + google_api_key;
return url;
}
You can find the geoencoding responses in the following link.
Google Maps Platform Geoencoding Guide
Directions API
/**
* Google Directions URL
* @param locOrigin
* @param locDestination
* @param google_api_key
* @return
*/
public static String getGoogleMapDirectionUrl(String locOrigin, String locDestination, String google_api_key)
{
// Building the url to the web service
String url = "https://maps.googleapis.com/maps/api/directions/json?"
+ "mode=walking"
+ "&origin=" + locOrigin
+ "&destination=" + locDestination
+ "&key=" + google_api_key;
return url;
}
Geolocation API
The Geolocation API returns a location and accuracy radius based on information about cell towers and WiFi nodes that the mobile client can detect. This document describes the protocol used to send this data to the server and to return a response to the client.
Geolocation requests are sent using POST to the following URL:
https://www.googleapis.com/geolocation/v1/geolocate?key=YOUR_API_KEY
Leave a comment