In this short article, I will explain how to get Latitude and Longitude using the address of a given location with the help of Google Maps API V3 (Version 3) and JavaScript.
 Google Map API V3: Get Latitude and Longitude of a location from Address
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>
    <textarea id="txtAddress" rows="3" cols="25"></textarea>
    <br />
    <input type="button" onclick="GetLocation()" value="Get Location" />
    <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
    <script type="text/javascript">
    <!--
        function GetLocation() {
            var geocoder = new google.maps.Geocoder();
            var address = document.getElementById("txtAddress").value;
            geocoder.geocode({ 'address': address }, function (results, status) {
                if (status == google.maps.GeocoderStatus.OK) {
                    var latitude = results[0].geometry.location.lat();
                    var longitude = results[0].geometry.location.lng();
                    alert("Latitude: " + latitude + "\nLongitude: " + longitude);
                } else {
                    alert("Request failed.")
                }
            });
        };
        //-->
    </script>
</body>
</html>
 
Explanation
I have made use of HTML <textarea> for allowing user enter the address of a location and an HTML button which will trigger the process of fetching the Latitude and Longitude using the Google Maps API.
As soon as the button is clicked the JavaScript click event handler is raised which executes the JavaScript function GetLocation which makes call to the Google Maps API which in turn returns the Latitude and Longitude based on the address provided for the location.
 
Note: Here I have not specified the API Key but you need to get one from the Google Maps API V3 in order to use on hosted server.
 

Demo
 
Downloads