I have eventually got this working, baring in mind that im a complete javascript beginner how does my code look. Are there any errors or anything i should be worried about ?
Example link is the same http://rayoflightes.com/gmaps/form1.php var geocoder = new google.maps.Geocoder(); function geocodePosition(pos) { geocoder.geocode({ latLng: pos }, function(responses) { if (responses && responses.length > 0) { updateMarkerAddress(responses[0].formatted_address); } else { updateMarkerAddress('Cannot determine address at this location.'); } }); } function updateMarkerStatus(str) { document.getElementById('markerStatus').innerHTML = str; } function updateMarkerPosition(latLng) { document.getElementById('latitude').value = [ latLng.lat() ]; document.getElementById('longitude').value = [ latLng.lng() ]; } function initialize() { var address = document.getElementById("address").value; var latLng = new google.maps.LatLng(-34.397, 150.644); var map = new google.maps.Map(document.getElementById('mapCanvas'), { zoom: 12, center: latLng, mapTypeId: google.maps.MapTypeId.SATELLITE }); geocoder.geocode( { 'address': address}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { map.setCenter(results[0].geometry.location); var marker = new google.maps.Marker({ map: map, draggable: true, position: results[0].geometry.location, }); map.setZoom(18); // Update current position info. updateMarkerPosition(latLng); geocodePosition(latLng); // Add dragging event listeners. google.maps.event.addListener(marker, 'dragstart', function() { updateMarkerAddress('Dragging...'); }); google.maps.event.addListener(marker, 'drag', function() { updateMarkerStatus('Dragging...'); updateMarkerPosition(marker.getPosition()); }); google.maps.event.addListener(marker, 'dragend', function() { updateMarkerStatus('Drag ended'); geocodePosition(marker.getPosition()); }); /* When geocoding "fails", see if it was because of over quota error: */ } else if (status == google.maps.GeocoderStatus.OVER_QUERY_LIMIT) { wait = true; setTimeout("wait = false", 1000); } else { alert("Geocode was not successful for the following reason: " + status); } }); } // Onload handler to fire off the app. google.maps.event.addDomListener(window, 'load', initialize); -- You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group. To view this discussion on the web visit https://groups.google.com/d/msg/google-maps-js-api-v3/-/24P0cp1USTAJ. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.
