<html> <head> <script> var geocoder; var map; function codeAddress() { geocoder = new google.maps.Geocoder(); var lat = ''; var lng = ''; var address = "swaminaray nagar nizampura, VADODARA - 390020"; geocoder.geocode({ 'address': address }, function (results, status) { if (status == google.maps.GeocoderStatus.OK) { lat = results[0].geometry.location.lat(); //getting the lat lng = results[0].geometry.location.lng(); //getting the lng map.setCenter(results[0].geometry.location); var marker = new google.maps.Marker({ map: map, position: results[0].geometry.location }); } else { alert("Geocode was not successful for the following reason: " + status); } }); var latlng = new google.maps.LatLng(lat, lng); var myOptions = { zoom: 8, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP } map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); } window.onload = function () { codeAddress(); } </script> </head> <body> <script src="http://maps.google.com/maps/api/js?libraries=places®ion=uk&language=en&sensor=true"></script> <div id="map_canvas" style="height: 350px; width: 900px; margin: 0.6em;"> </div> </body> </html>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)