I am implementing Google maps V3, I have a feature to search a location by proving address like ‘5415 E High St. Suite 460, Phoenix, AZ, 85054’ and searching through geocoder and it is not providing me any result. Below is my code snippet. I have searched this same address in bing and it is providing me correct location.
var geocoder;
geocoder = new google.maps.Geocoder();
var address = document.getElementById('txtLocation').value;
geocoder.geocode({ 'address': address }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
marker = new google.maps.Marker({
map: map,
zoom: 15,
position: results[0].geometry.location,
dragable: true
});
Please let me know where am i going wrong and what should i do to get correct location.
Make sure you’re closing your braces and function calls. When I made your example into valid JavaScript I had no problem getting it to work:
You can see it in action on this jsbin