{"id":690,"date":"2014-07-05T11:22:32","date_gmt":"2014-07-05T11:22:32","guid":{"rendered":"http:\/\/www.siriinnovations.com\/blog\/?p=690"},"modified":"2014-07-09T11:08:16","modified_gmt":"2014-07-09T11:08:16","slug":"get-latlng-google-maps-using-address","status":"publish","type":"post","link":"https:\/\/siriinnovations.com\/blog\/get-latlng-google-maps-using-address\/","title":{"rendered":"Get Latitude and Longitude from Google maps using address"},"content":{"rendered":"<p>Find the code below to get Latitude and Longitude\u00a0from Google Maps using address.<\/p>\n<pre class=\"code\" lang=\"php\">\/* \r\n* Given an address, return the longitude and latitude using The Google Geocoding API V3\r\n*\r\n*\/\r\nfunction Get_LatLng_From_Google_Maps($address) {\r\n\t\/\/$address = \"1600+Amphitheatre+Parkway,+Mountain+View,+CA\";\r\n\t$url = \"http:\/\/maps.googleapis.com\/maps\/api\/geocode\/json?address=$address&amp;sensor=false\";\r\n\t\/\/ Make the HTTP request\r\n\t$data = @file_get_contents($url);\r\n\t\/\/ Parse the json response\r\n\t$jsondata = json_decode($data,true);\r\n\t\/\/ If the json data is invalid, return empty array\r\n\tif (!$this-&gt;check_status($jsondata))\treturn array();\r\n\t$LatLng = array(\r\n\t    'lat' =&gt; $jsondata[\"results\"][0][\"geometry\"][\"location\"][\"lat\"],\r\n\t    'lng' =&gt; $jsondata[\"results\"][0][\"geometry\"][\"location\"][\"lng\"],\r\n\t    'formatted_address' =&gt; $jsondata[\"results\"][0][\"formatted_address\"],\r\n\t);\r\n\treturn $LatLng;\r\n}\r\n\/* \r\n* Check if the json data from Google Geo is valid \r\n*\/function check_status($jsondata) {\r\n\tif ($jsondata[\"status\"] == \"OK\") return true;\r\n\treturn false;\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Find the code below to get Latitude and Longitude\u00a0from Google Maps using address. \/* * Given an address, return the longitude and latitude using The Google Geocoding API V3 * *\/ function Get_LatLng_From_Google_Maps($address) { \/\/$address = &#8220;1600+Amphitheatre+Parkway,+Mountain+View,+CA&#8221;; $url = &#8220;http:\/\/maps.googleapis.com\/maps\/api\/geocode\/json?address=$address&amp;sensor=false&#8221;; \/\/ Make the HTTP request $data = @file_get_contents($url); \/\/ Parse the json response $jsondata = [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":991,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-690","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-general"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Get Latitude and Longitude from Google maps using address - Siri Innovations<\/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:\/\/siriinnovations.com\/blog\/get-latlng-google-maps-using-address\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Get Latitude and Longitude from Google maps using address - Siri Innovations\" \/>\n<meta property=\"og:description\" content=\"Find the code below to get Latitude and Longitude\u00a0from Google Maps using address. \/* * Given an address, return the longitude and latitude using The Google Geocoding API V3 * *\/ function Get_LatLng_From_Google_Maps($address) { \/\/$address = &quot;1600+Amphitheatre+Parkway,+Mountain+View,+CA&quot;; $url = &quot;http:\/\/maps.googleapis.com\/maps\/api\/geocode\/json?address=$address&amp;sensor=false&quot;; \/\/ Make the HTTP request $data = @file_get_contents($url); \/\/ Parse the json response $jsondata = [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/siriinnovations.com\/blog\/get-latlng-google-maps-using-address\/\" \/>\n<meta property=\"og:site_name\" content=\"Siri Innovations\" \/>\n<meta property=\"article:published_time\" content=\"2014-07-05T11:22:32+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-07-09T11:08:16+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/siriinnovations.com\/blog\/wp-content\/uploads\/2014\/07\/4.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"540\" \/>\n\t<meta property=\"og:image:height\" content=\"241\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Shilpa Buddha\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Shilpa Buddha\" \/>\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\":\"Article\",\"@id\":\"https:\/\/siriinnovations.com\/blog\/get-latlng-google-maps-using-address\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/siriinnovations.com\/blog\/get-latlng-google-maps-using-address\/\"},\"author\":{\"name\":\"Shilpa Buddha\",\"@id\":\"https:\/\/siriinnovations.com\/blog\/#\/schema\/person\/e8e1f72a882fe505ca12b49a7d1d8f5d\"},\"headline\":\"Get Latitude and Longitude from Google maps using address\",\"datePublished\":\"2014-07-05T11:22:32+00:00\",\"dateModified\":\"2014-07-09T11:08:16+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/siriinnovations.com\/blog\/get-latlng-google-maps-using-address\/\"},\"wordCount\":23,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/siriinnovations.com\/blog\/get-latlng-google-maps-using-address\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/siriinnovations.com\/blog\/wp-content\/uploads\/2014\/07\/4.jpg\",\"articleSection\":[\"General\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/siriinnovations.com\/blog\/get-latlng-google-maps-using-address\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/siriinnovations.com\/blog\/get-latlng-google-maps-using-address\/\",\"url\":\"https:\/\/siriinnovations.com\/blog\/get-latlng-google-maps-using-address\/\",\"name\":\"Get Latitude and Longitude from Google maps using address - Siri Innovations\",\"isPartOf\":{\"@id\":\"https:\/\/siriinnovations.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/siriinnovations.com\/blog\/get-latlng-google-maps-using-address\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/siriinnovations.com\/blog\/get-latlng-google-maps-using-address\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/siriinnovations.com\/blog\/wp-content\/uploads\/2014\/07\/4.jpg\",\"datePublished\":\"2014-07-05T11:22:32+00:00\",\"dateModified\":\"2014-07-09T11:08:16+00:00\",\"author\":{\"@id\":\"https:\/\/siriinnovations.com\/blog\/#\/schema\/person\/e8e1f72a882fe505ca12b49a7d1d8f5d\"},\"breadcrumb\":{\"@id\":\"https:\/\/siriinnovations.com\/blog\/get-latlng-google-maps-using-address\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/siriinnovations.com\/blog\/get-latlng-google-maps-using-address\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/siriinnovations.com\/blog\/get-latlng-google-maps-using-address\/#primaryimage\",\"url\":\"https:\/\/siriinnovations.com\/blog\/wp-content\/uploads\/2014\/07\/4.jpg\",\"contentUrl\":\"https:\/\/siriinnovations.com\/blog\/wp-content\/uploads\/2014\/07\/4.jpg\",\"width\":540,\"height\":241},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/siriinnovations.com\/blog\/get-latlng-google-maps-using-address\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/siriinnovations.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Get Latitude and Longitude from Google maps using address\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/siriinnovations.com\/blog\/#website\",\"url\":\"https:\/\/siriinnovations.com\/blog\/\",\"name\":\"Technical blog from Siri Innovations\",\"description\":\"Innovative like no other\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/siriinnovations.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/siriinnovations.com\/blog\/#\/schema\/person\/e8e1f72a882fe505ca12b49a7d1d8f5d\",\"name\":\"Shilpa Buddha\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/siriinnovations.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c4d3d50337b9882c866fe638d3af530f0503e9e499ee77e4e53f9e34605abbe5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c4d3d50337b9882c866fe638d3af530f0503e9e499ee77e4e53f9e34605abbe5?s=96&d=mm&r=g\",\"caption\":\"Shilpa Buddha\"},\"url\":\"https:\/\/siriinnovations.com\/blog\/author\/shilpa-buddha\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Get Latitude and Longitude from Google maps using address - Siri Innovations","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:\/\/siriinnovations.com\/blog\/get-latlng-google-maps-using-address\/","og_locale":"en_US","og_type":"article","og_title":"Get Latitude and Longitude from Google maps using address - Siri Innovations","og_description":"Find the code below to get Latitude and Longitude\u00a0from Google Maps using address. \/* * Given an address, return the longitude and latitude using The Google Geocoding API V3 * *\/ function Get_LatLng_From_Google_Maps($address) { \/\/$address = \"1600+Amphitheatre+Parkway,+Mountain+View,+CA\"; $url = \"http:\/\/maps.googleapis.com\/maps\/api\/geocode\/json?address=$address&amp;sensor=false\"; \/\/ Make the HTTP request $data = @file_get_contents($url); \/\/ Parse the json response $jsondata = [&hellip;]","og_url":"https:\/\/siriinnovations.com\/blog\/get-latlng-google-maps-using-address\/","og_site_name":"Siri Innovations","article_published_time":"2014-07-05T11:22:32+00:00","article_modified_time":"2014-07-09T11:08:16+00:00","og_image":[{"width":540,"height":241,"url":"https:\/\/siriinnovations.com\/blog\/wp-content\/uploads\/2014\/07\/4.jpg","type":"image\/jpeg"}],"author":"Shilpa Buddha","twitter_misc":{"Written by":"Shilpa Buddha","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/siriinnovations.com\/blog\/get-latlng-google-maps-using-address\/#article","isPartOf":{"@id":"https:\/\/siriinnovations.com\/blog\/get-latlng-google-maps-using-address\/"},"author":{"name":"Shilpa Buddha","@id":"https:\/\/siriinnovations.com\/blog\/#\/schema\/person\/e8e1f72a882fe505ca12b49a7d1d8f5d"},"headline":"Get Latitude and Longitude from Google maps using address","datePublished":"2014-07-05T11:22:32+00:00","dateModified":"2014-07-09T11:08:16+00:00","mainEntityOfPage":{"@id":"https:\/\/siriinnovations.com\/blog\/get-latlng-google-maps-using-address\/"},"wordCount":23,"commentCount":0,"image":{"@id":"https:\/\/siriinnovations.com\/blog\/get-latlng-google-maps-using-address\/#primaryimage"},"thumbnailUrl":"https:\/\/siriinnovations.com\/blog\/wp-content\/uploads\/2014\/07\/4.jpg","articleSection":["General"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/siriinnovations.com\/blog\/get-latlng-google-maps-using-address\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/siriinnovations.com\/blog\/get-latlng-google-maps-using-address\/","url":"https:\/\/siriinnovations.com\/blog\/get-latlng-google-maps-using-address\/","name":"Get Latitude and Longitude from Google maps using address - Siri Innovations","isPartOf":{"@id":"https:\/\/siriinnovations.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/siriinnovations.com\/blog\/get-latlng-google-maps-using-address\/#primaryimage"},"image":{"@id":"https:\/\/siriinnovations.com\/blog\/get-latlng-google-maps-using-address\/#primaryimage"},"thumbnailUrl":"https:\/\/siriinnovations.com\/blog\/wp-content\/uploads\/2014\/07\/4.jpg","datePublished":"2014-07-05T11:22:32+00:00","dateModified":"2014-07-09T11:08:16+00:00","author":{"@id":"https:\/\/siriinnovations.com\/blog\/#\/schema\/person\/e8e1f72a882fe505ca12b49a7d1d8f5d"},"breadcrumb":{"@id":"https:\/\/siriinnovations.com\/blog\/get-latlng-google-maps-using-address\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/siriinnovations.com\/blog\/get-latlng-google-maps-using-address\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/siriinnovations.com\/blog\/get-latlng-google-maps-using-address\/#primaryimage","url":"https:\/\/siriinnovations.com\/blog\/wp-content\/uploads\/2014\/07\/4.jpg","contentUrl":"https:\/\/siriinnovations.com\/blog\/wp-content\/uploads\/2014\/07\/4.jpg","width":540,"height":241},{"@type":"BreadcrumbList","@id":"https:\/\/siriinnovations.com\/blog\/get-latlng-google-maps-using-address\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/siriinnovations.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Get Latitude and Longitude from Google maps using address"}]},{"@type":"WebSite","@id":"https:\/\/siriinnovations.com\/blog\/#website","url":"https:\/\/siriinnovations.com\/blog\/","name":"Technical blog from Siri Innovations","description":"Innovative like no other","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/siriinnovations.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/siriinnovations.com\/blog\/#\/schema\/person\/e8e1f72a882fe505ca12b49a7d1d8f5d","name":"Shilpa Buddha","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/siriinnovations.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c4d3d50337b9882c866fe638d3af530f0503e9e499ee77e4e53f9e34605abbe5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c4d3d50337b9882c866fe638d3af530f0503e9e499ee77e4e53f9e34605abbe5?s=96&d=mm&r=g","caption":"Shilpa Buddha"},"url":"https:\/\/siriinnovations.com\/blog\/author\/shilpa-buddha\/"}]}},"jetpack_featured_media_url":"https:\/\/siriinnovations.com\/blog\/wp-content\/uploads\/2014\/07\/4.jpg","_links":{"self":[{"href":"https:\/\/siriinnovations.com\/blog\/wp-json\/wp\/v2\/posts\/690","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/siriinnovations.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/siriinnovations.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/siriinnovations.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/siriinnovations.com\/blog\/wp-json\/wp\/v2\/comments?post=690"}],"version-history":[{"count":6,"href":"https:\/\/siriinnovations.com\/blog\/wp-json\/wp\/v2\/posts\/690\/revisions"}],"predecessor-version":[{"id":992,"href":"https:\/\/siriinnovations.com\/blog\/wp-json\/wp\/v2\/posts\/690\/revisions\/992"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/siriinnovations.com\/blog\/wp-json\/wp\/v2\/media\/991"}],"wp:attachment":[{"href":"https:\/\/siriinnovations.com\/blog\/wp-json\/wp\/v2\/media?parent=690"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/siriinnovations.com\/blog\/wp-json\/wp\/v2\/categories?post=690"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/siriinnovations.com\/blog\/wp-json\/wp\/v2\/tags?post=690"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}