Here is an idea. Refer to this SO Question. The first answer has a link to an XML file with the polygon coordinates for all the state boundaries. You could also simplify the polygons so there are not so many vertices.
When a marker is added to the map you can check to see if it exists in one of the 50 point arrays using an algorithm like this:
UPDATE: the original function I posted was not in javascript. Here is a Javascript one and a fiddle of it working:
/*
* state == array of Google LatLng objects.
* lat == latitude to test
* lng == longitude to test
*/
function pointInPolygon(state, lat, lng) {
var polyCount = state.length;
var oddNodes = false;
var j = 0;
for (var i = 0; i < polyCount; i++) {
j++;
if (j == polyCount) {
j = 0;
}
latitudeBoundry = state[i].lat();
longitudeBoundry = state[i].lng();
latitudeBoundry2 = state[j].lat();
longitudeBoundry2 = state[j].lng();
if ((latitudeBoundry > lat && latitudeBoundry <= lat
|| latitudeBoundry2 > lat && latitudeBoundry <= lat)) {
if (longitudeBoundry + (lat - latitudeBoundry)
/ (latitudeBoundry2 - latitudeBoundry)
* (longitudeBoundry2 - longitudeBoundry) > lng) {
oddNodes = !oddNodes
}
}
}
return oddNodes;
}
If it exists increment a counter.
Once you have found the state with the most markers you can set the zoom by creating a bounds object.
//the polyArray is the array of points for the target state.
var bounds = new google.maps.LatLngBounds();
for ( var i = 0; i < polyArray.length; i++ )
{
bounds.extend( polyArray[ i ] );
}
//set the map viewport
map.fitBounds(bounds)
I have no idea about how this will pan out performance wise, but it should be much faster than reverse geocoding.