I've taken code that I had written a while ago for another web application and used it for another. However, for no obvious reason, it's not retrieving results:
Geocode was not successful for the following reason: ZERO_RESULTS
I have the following code, which — as implied — is functioning with no problems elsewhere:
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script type="text/javascript">
function googleMaps (lat, lng, zoom) {
geocoder = new google.maps.Geocoder();
var myLatlng = new google.maps.LatLng(lat, lng);
var myOptions = {
zoom: zoom,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.TERRAIN
}
map = new google.maps.Map(document.getElementById("map-locations"), myOptions);
var marker = new google.maps.Marker({
position: myLatlng,
map: map
});
google.maps.event.addListener(map, "center_changed", function(){
document.getElementById("latitude").value = map.getCenter().lat();
document.getElementById("longitude").value = map.getCenter().lng();
marker.setPosition(map.getCenter());
document.getElementById("zoom").value = map.getZoom();
});
google.maps.event.addListener(map, "zoom_changed", function(){
document.getElementById("zoom").value = map.getZoom();
});
}
$(document).ready(function() {
googleMaps(52.3555, -1.1743, 6);
});
</script>
<script>
$(document).ready(function(){
$("#address").change(function(){
geocoder.geocode({
"address": $(this).attr("value")
}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setZoom(14);
map.setCenter(results[0].geometry.location);
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
});
})
</script>
I also have the "canvas" and corresponding address field, which are identical to the functioning version elsewhere.
As an aside, I went through the Google API procedure to create an API key, which I appear not to have had to do with the earlier version. But with or without the API key, it won't function.
So I'm wondering if this process has somehow broken things.