var geocoder;
var map;
var myOptions;

function initialize(center) {
	geocoder = new google.maps.Geocoder();
    var myOptions = {
      zoom: 13,
      mapTypeId: google.maps.MapTypeId.ROADMAP,
      mapTypeControl: 0
    };
    map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    
	geocoder.geocode( { address: center}, function(results, status) {
		if (status == google.maps.GeocoderStatus.OK && results.length) {
			if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {
			    map.set_center(results[0].geometry.location);
			}
		} else {
			alert("Geocode was unsuccessful due to: " + status);
		}
	});
	codeAddress("Chichester");
	codeAddress("Crawley");
	codeAddress("Worthing"); 
}
	
function codeAddress(address) {
	geocoder.geocode( { address: address}, function(results, status) {
		if (status == google.maps.GeocoderStatus.OK && results.length) {
			// You should always check that a result was returned, as it is
			// possible to return an empty results object.
			if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {
				var marker = new google.maps.Marker({
					position: results[0].geometry.location,
					map: map,
					title: address
				});
			}
		} else {
			alert("Geocode was unsuccessful due to: " + status);
		}
	});
}