Get Latitude Longitude from Address Using Google API and JavaScript

Get Latitude Longitude from Address Using Google API and JavaScript

In this tutorial we will show you how to convert address into Latitude Longitude with the help of JavaScript and google map API.

Get Latitude Longitude is a very simple you can fetch form any kind of address using JS and Google API.

Here we are creating a simple text box and button inside text box enter your address and click on button after click Latitude Longitude will be show into other textboxes.

How to fetch Latitude and Longitude From Address using Google Map API & JavaScript

<!doctype html>
<html lang="en">
	<meta charset="UTF-8">
	<meta http-equiv="x-ua-compatible" content="ie=edge">
	<script src="" async defer></script>

	function getLatLong()
		var address = document.getElementById("address").value;
		var geocoder = new google.maps.Geocoder();
		geocoder.geocode( { 'address': address}, function(results, status) {
			if (status == google.maps.GeocoderStatus.OK) {
				var latitude = results[0];
				var longitude = results[0].geometry.location.lng();
	<input type="text" name="address" id="address" style="width:100%;">
	<input type="button" onclick="return getLatLong()" value="Get Lat Long" />
<div id="latlong">
	<p>Latitude: <input size="20" type="text" id="latbox" name="lat" ></p>
	<p>Longitude: <input size="20" type="text" id="lngbox" name="lng" ></p>

Tags for get latitude and longitude from address:

latitude and longitude to address, latitude and longitude of my location, get latitude and longitude from address, get lat an dlog from address, find latitude and longitude from address, latitude and longitude map, Get Lat Long from Address Convert Address to Coordinates, Latitude and Longitude Finder on Map Get Coordinates, Convert Lat Long to Address Show on Map, Javascript geocoding from address to latitude and longitude, Finding the latitude and longitude by address with the Google Maps

About Author

My name is Mukesh Jakhar and I am a Web Application Developer and Software Developer, currently living in Jaipur, India. I have a Master of Computer Application in Computer Science from JNU Jaipur University. I loves to write on technology and programming topics. Apart from this, I love to travel and enjoy the beauty of nature.

Sign up for weekly update

Milkshake is almost ready. If you're interested in testing it out, then sign up below to get exclusive access.