Search code examples
.netgoogle-maps-api-3google-geocoder

Is it possible to geocode via googles geocoder via city/state/address rather than just address?


I have created a lot of applications that use the Google Maps Api V3. I have just run into an instance where I have a city, state, address and I need to geocode off all three of these pieces. Every example I have seen and currently use in my code go specifically off of address. What I have and have seen for geocoding are very similar to Google's main example which I have pasted here. :

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);
      }
    });
  }

As you can see it is just going off of address, I can't do this for my application as some of my addresses are really vague and will come back with numerous results just wondering if anyone has figured out how to do this?

I searched the forums here and found some similar questions but no real answers. Any comments/advice are greatly appreciated.


Solution

  • Ok, completely misinterpreted how this address field works. You can just shove city state on the end of the address field.

    http://www.jasonfulps.com/node/288