Hey Guiz, when nothing worked for me, I planned to use this approach .. and it worked for me .. I took the coordinates from the viewport and then matched the same with the limitations .. this approach works.
function codeAddress() { var address = document.getElementById('address').value; if(address == null || address== "") { alert('Address field is Empty.. !'); } else { geocoder.geocode({ 'address' : address }, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { // If geocoder status is OK then locate the geometry,.. var location = results[0].geometry.location // Obtaining the lat lang of new position on map.. var latlng = new google.maps.LatLng(location.lat(),location.lng()); map.setCenter(location); // view port gives us the map bounds for a particular location.. **var viewportloc = String(results[0].geometry.viewport); var res = viewportloc.replace('((','').replace('))','').replace('(','').replace(')','').split(','); //alert(res[0]+" - "+res[1]+" - "+res[2]+" - "+res[3]); var sw = new google.maps.LatLng(res[0],res[1]); var ne = new google.maps.LatLng(res[2],res[3]); var bounds = new google.maps.LatLngBounds(); bounds.extend(sw); bounds.extend(ne); map.fitBounds(bounds);** addMarker(location); setonMap(map); } else { document.getElementById('address').value = ""; alert('Geocode was not successful for the following reason: ' + status); } }); } }
Vrajendra singh mandloi
source share