I can get the City coordinates using the GeoCoder API and input that into my GMaps API so that it centers on that address/coords. I'd like to just pass in the state name to the API and get the center coordinates for that state if possible. I havn't seen any options under address
params in the GeoCoder API to only pass in a state name. Any ideas?
Current Implementation works with centering on City:
function getStateBounds ( state ) {
var geocoder = new google.maps.Geocoder();
var latlong;
geocoder.geocode( { 'latLng': new google.maps.LatLng(latitude, longitude)}, function(results, status)
{
if ( status === google.maps.GeocoderStatus.OK )
{
latlong = (results[0].geometry.location);
var lat = latlong.lat();
var long = latlong.lng();
// Wasn't working setting inside this method :|
$scope.setStateCoordsScope( lat, long );
} else {
alert( "Geocode was not successful for the following reason: " + status );
}
});
}
latitude and longitude variables are for City only, but I have access to the State string as well.
EDIT: If I only pass in state string, it will do a wrong lookup with states that have matching city names, e.g. Washington.