I did my maps like this to avoid the error code displaying if there is no results/ no entry made in the selected fields. But if there is no result from a search with the fields populated I feel you should at least show the users why the map did not populate.
function codeAddress(mapdir) {
address = document.getElementById("LocAddress1").value + " " + document.getElementById("LocAddress2").value + " " + document.getElementById("LocTown").value;
if (geocoder != null) {
if (address != " ") {
if (mapdir != " ") {
address = mapdir;
geocoder.geocode({ 'address': address }, function (results, status) {
marker.setMap(null);
if (status == google.maps.GeocoderStatus.OK) {
document.getElementById("lblGeoLocation").innerHTML = results[0].geometry.location;
document.getElementById("StaticMap").value = results[0].geometry.location;
map.setCenter(results[0].geometry.location);
marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
if (status == "ZERO_RESULTS") {
alert('Geocode was not successful for the following reason: ' + status);
}
else {
}
}
});
}
Hope this helps.
If this does not solve the problem please lect me know so that I can remove this as an answer.