{"id":3212,"date":"2011-04-14T15:54:11","date_gmt":"2011-04-14T13:54:11","guid":{"rendered":"http:\/\/blog.jteam.nl\/?p=3212"},"modified":"2011-04-14T15:54:11","modified_gmt":"2011-04-14T13:54:11","slug":"using-google-geocoding-api-with-geocoder","status":"publish","type":"post","link":"https:\/\/trifork.nl\/blog\/using-google-geocoding-api-with-geocoder\/","title":{"rendered":"Using Google Geocoding API with Geocoder"},"content":{"rendered":"<p lang=\"en-US\">I was looking for a way to retrieve latitude and longitude for a given address. I thought that Google could provide me with a solution and eventually it did. First I was looking at the <a href=\"http:\/\/code.google.com\/apis\/gdata\/\">Google Data API<\/a>, but found that some parts were deprecated and not supported anymore. The <a href=\"http:\/\/code.google.com\/apis\/maps\/documentation\/geocoding\/\">Google Geocoding API<\/a>, that is part of the <a href=\"http:\/\/code.google.com\/apis\/maps\/documentation\/webservices\/index.html\">Google Maps API<\/a>, should be used. You can execute a request. The response will be in JSON or XML format. Next to that there is a nice Java API called the <a href=\"http:\/\/code.google.com\/p\/geocoder-java\/\">Geocoder<\/a>. Through this API it is easy to obtain<a href=\"http:\/\/code.google.com\/p\/geocoder-java\/\"> <\/a> geographical information.<\/p>\n<p lang=\"en-US\">The following example shows how to retrieve latitude and longitude in a test:<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\n@Test\npublic void testGetLocation() {\n    final Geocoder geocoder = new Geocoder();\n    GeocoderRequest geocoderRequest = new GeocoderRequestBuilder().setAddress(&quot;Rijnsburgstraat 9-11, Amsterdam, The Netherlands&quot;).getGeocoderRequest();\n    GeocodeResponse geocoderResponse = geocoder.geocode(geocoderRequest);\n    List&lt;GeocoderResult&gt; results = geocoderResponse.getResults();\n    float latitude = results.get(0).getGeometry().getLocation().getLat().floatValue();\n    float longitude = results.get(0).getGeometry().getLocation().getLng().floatValue();\n    assertEquals(52.347797f, latitude);\n    assertEquals(4.8507648f, longitude);\n}\n<\/pre>\n<p lang=\"en-US\">If you want to use this in your project, you can obtain the Java client from a Maven repository. The following code block shows the Maven configuration of the artifact:<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n&lt;dependency&gt;\n    &lt;groupId&gt;com.google.code.geocoder-java&lt;\/groupId&gt;\n    &lt;artifactId&gt;geocoder-java&lt;\/artifactId&gt;\n    &lt;version&gt;0.5&lt;\/version&gt;\n&lt;\/dependency&gt;\n<\/pre>\n<p lang=\"en-US\">Now you can determine the latitude and longitude of the place where you live!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was looking for a way to retrieve latitude and longitude for a given address. I thought that Google could provide me with a solution and eventually it did. First I was looking at the Google Data API, but found that some parts were deprecated and not supported anymore. The Google Geocoding API, that is [&hellip;]<\/p>\n","protected":false},"author":33,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"content-type":"","footnotes":""},"categories":[31],"tags":[239,240,241,242],"class_list":["post-3212","post","type-post","status-publish","format-standard","hentry","category-java","tag-geocoder","tag-geocoding","tag-google","tag-java-api"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Using Google Geocoding API with Geocoder - Trifork Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/trifork.nl\/blog\/using-google-geocoding-api-with-geocoder\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using Google Geocoding API with Geocoder - Trifork Blog\" \/>\n<meta property=\"og:description\" content=\"I was looking for a way to retrieve latitude and longitude for a given address. I thought that Google could provide me with a solution and eventually it did. First I was looking at the Google Data API, but found that some parts were deprecated and not supported anymore. The Google Geocoding API, that is [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/trifork.nl\/blog\/using-google-geocoding-api-with-geocoder\/\" \/>\n<meta property=\"og:site_name\" content=\"Trifork Blog\" \/>\n<meta property=\"article:published_time\" content=\"2011-04-14T13:54:11+00:00\" \/>\n<meta name=\"author\" content=\"Denis Tunovi\u0107\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Denis Tunovi\u0107\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/trifork.nl\/blog\/using-google-geocoding-api-with-geocoder\/\",\"url\":\"https:\/\/trifork.nl\/blog\/using-google-geocoding-api-with-geocoder\/\",\"name\":\"Using Google Geocoding API with Geocoder - Trifork Blog\",\"isPartOf\":{\"@id\":\"https:\/\/trifork.nl\/blog\/#website\"},\"datePublished\":\"2011-04-14T13:54:11+00:00\",\"author\":{\"@id\":\"https:\/\/trifork.nl\/blog\/#\/schema\/person\/4775eda181e3a29deebe1805dca85253\"},\"breadcrumb\":{\"@id\":\"https:\/\/trifork.nl\/blog\/using-google-geocoding-api-with-geocoder\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/trifork.nl\/blog\/using-google-geocoding-api-with-geocoder\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/trifork.nl\/blog\/using-google-geocoding-api-with-geocoder\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/trifork.nl\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Using Google Geocoding API with Geocoder\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/trifork.nl\/blog\/#website\",\"url\":\"https:\/\/trifork.nl\/blog\/\",\"name\":\"Trifork Blog\",\"description\":\"Keep updated on the technical solutions Trifork is working on!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/trifork.nl\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/trifork.nl\/blog\/#\/schema\/person\/4775eda181e3a29deebe1805dca85253\",\"name\":\"Denis Tunovi\u0107\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/trifork.nl\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/9fdecfbf048b60323e98f65d8b7475a5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/9fdecfbf048b60323e98f65d8b7475a5?s=96&d=mm&r=g\",\"caption\":\"Denis Tunovi\u0107\"},\"url\":\"https:\/\/trifork.nl\/blog\/author\/denis\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using Google Geocoding API with Geocoder - Trifork Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/trifork.nl\/blog\/using-google-geocoding-api-with-geocoder\/","og_locale":"en_US","og_type":"article","og_title":"Using Google Geocoding API with Geocoder - Trifork Blog","og_description":"I was looking for a way to retrieve latitude and longitude for a given address. I thought that Google could provide me with a solution and eventually it did. First I was looking at the Google Data API, but found that some parts were deprecated and not supported anymore. The Google Geocoding API, that is [&hellip;]","og_url":"https:\/\/trifork.nl\/blog\/using-google-geocoding-api-with-geocoder\/","og_site_name":"Trifork Blog","article_published_time":"2011-04-14T13:54:11+00:00","author":"Denis Tunovi\u0107","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Denis Tunovi\u0107","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/trifork.nl\/blog\/using-google-geocoding-api-with-geocoder\/","url":"https:\/\/trifork.nl\/blog\/using-google-geocoding-api-with-geocoder\/","name":"Using Google Geocoding API with Geocoder - Trifork Blog","isPartOf":{"@id":"https:\/\/trifork.nl\/blog\/#website"},"datePublished":"2011-04-14T13:54:11+00:00","author":{"@id":"https:\/\/trifork.nl\/blog\/#\/schema\/person\/4775eda181e3a29deebe1805dca85253"},"breadcrumb":{"@id":"https:\/\/trifork.nl\/blog\/using-google-geocoding-api-with-geocoder\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/trifork.nl\/blog\/using-google-geocoding-api-with-geocoder\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/trifork.nl\/blog\/using-google-geocoding-api-with-geocoder\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/trifork.nl\/blog\/"},{"@type":"ListItem","position":2,"name":"Using Google Geocoding API with Geocoder"}]},{"@type":"WebSite","@id":"https:\/\/trifork.nl\/blog\/#website","url":"https:\/\/trifork.nl\/blog\/","name":"Trifork Blog","description":"Keep updated on the technical solutions Trifork is working on!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/trifork.nl\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/trifork.nl\/blog\/#\/schema\/person\/4775eda181e3a29deebe1805dca85253","name":"Denis Tunovi\u0107","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/trifork.nl\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/9fdecfbf048b60323e98f65d8b7475a5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9fdecfbf048b60323e98f65d8b7475a5?s=96&d=mm&r=g","caption":"Denis Tunovi\u0107"},"url":"https:\/\/trifork.nl\/blog\/author\/denis\/"}]}},"_links":{"self":[{"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/posts\/3212","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/users\/33"}],"replies":[{"embeddable":true,"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/comments?post=3212"}],"version-history":[{"count":0,"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/posts\/3212\/revisions"}],"wp:attachment":[{"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/media?parent=3212"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/categories?post=3212"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/trifork.nl\/blog\/wp-json\/wp\/v2\/tags?post=3212"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}