title: Cannot read property 'geocode' of undefined
body: <pre class="lang-js prettyprint-override"><code>var geocoder;
  var map;
  var infowindow;
  
  function initialize() {
    geocoder = new google.maps.Geocoder();
    var loca = new google.maps.LatLng(41.7475, -74.0872);
  
    map = new google.maps.Map(document.getElementById('map'), {
      mapTypeId: google.maps.MapTypeId.ROADMAP,
      center: loca,
      zoom: 8
    });
  
  }
  
  function callback(results, status) {
    if (status == google.maps.places.PlacesServiceStatus.OK) {
      for (var i = 0; i &lt; results.length; i++) {
        createMarker(results[i]);
      }
    }
  }
  
  function createMarker(place) {
    var placeLoc = place.geometry.location;
    var marker = new google.maps.Marker({
      map: map,
      position: place.geometry.location
    });
  
    google.maps.event.addListener(marker, 'mouseover', function() {
      infowindow.setContent(place.name);
      infowindow.open(map, this);
    });
  }
  
  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
        });
        var request = {
          location: results[0].geometry.location,
          radius: 50000,
          name: 'ski',
          keyword: 'mountain',
          type: ['park']
        };
        infowindow = new google.maps.InfoWindow();
        var service = new google.maps.places.PlacesService(map);
        service.nearbySearch(request, callback);
      } else {
        alert("Geocode was not successful for the following reason: " + status);
      }
    });
  }
  
  google.maps.event.addDomListener(window, 'load', initialize);
  </code></pre>
  
  
  
  <p>My application currently finds the nearest ski areas, based on the latitude and longitude that is hardcoded in. I would like to be able to type in an address and convert that address into the latitude and longitude for the search. I am using Google Maps api and the places library. I know that I somehow need to use geocoding but not sure how to do that. Here is the code:</p>