Hi there Ashley and thanks very much for your help,
Here's the javascript in the head:
<script type="text/javascript">
//Declare the variable that will store the geocode object
var geocoder;
var map;
function initialize() {
//Set the geocoder variable equal to an instance of the google maps geocoder object as new google.maps.Geocoder()
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(42.095287, -79.3185139);
var myOptions = {
zoom: 2,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
}
//Add a second function to your javascript code, call it codeAddress. It will not have any values passed to it.
function codeAddress() {
//The first line of the function should use getElementById to get the address from the text box and place it
//into a variable we'll call sAddress.
var sAddress = document.getElementById("inputTextAddress").value;
//Call the geocode method of the geocoder object, this will take two passed in parameters. The first is
//the GeocoderRequest, this says what kind of request is being made and what the request value is.
//The second is the callback function that will be used to process the results.
geocoder.geocode( { 'address': sAddress}, function(results, status) {
//The callback function should first check the status value of the callback function. Use an IF statement
//to test the result, check to see if the status equal google.maps.GeocoderStatus.OK. Also add an
//ELSE clause to the if statement as well.
if (status == google.maps.GeocoderStatus.OK) {
//If the status equals OK, call the setCenter method of the map object variable. You will pass this
//method the results first geometry location.
map.setCenter(results[0].geometry.location);
//Next use the same result geometry location to add a map marker to the map object variable. Create a new
//variable, we'll call it oMarker, it will be created as a new google.maps.Marker. The new method take two
//parmaters, the first is the map object that you're adding the marker to, and the second is the
//position to place the marker which is again the first results geometry location.
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
//Finally we're going to add an alert message to the ELSE to let the user know that the Geocode didn't
//work like it should have. You can use the status to give a bit more information rather than just saying
//that it didn't work.
alert("Geocode was not successful for the following reason: " + status);
}
});
}
</script>
So it looks like the info I need is in:
position: results[0].geometry.location
but I'm not sure how to enter that as a value in:
<input type='hidden' name='geolocation' value'?' />