Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
   <style type="text/css">
     html { height: 100% }
     body { height: 100%; margin: 0; padding: 0 }
     #googleMap { height: 100% }
  </style>
  <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=places"></script>
<script>
var geocoder;
var map;
function initialize() {
var input = document.getElementById('address');
var options = {
  
  componentRestrictions: {country: "in"}
 };
var autocomplete = new google.maps.places.Autocomplete(input,options);
geocoder = new google.maps.Geocoder();
 
  var latlng = new google.maps.LatLng(18.52043030000, 73.85674369999);
  
  var mapOptions = {
    zoom: 15,
    center: latlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
   
  }
  
   map = new google.maps.Map(document.getElementById('googleMap'), mapOptions);
  
}
function codeAddress() {
  var address = document.getElementById('address').value;
  
  
  geocoder.geocode( { 'address': address}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK) {
    
     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);
    }
  });
}
  
  google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
    <input id="address" type="textbox" size="50">
    <input type="button" value="Search" onclick="codeAddress()"> 
    <div id="googleMap">        
    </div>
</body>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers