0

gmaps.js is a great library but it returns latitude and longitude successfully even for an incomplete / wrong address.

Example in the image below I searched for 1111 address and it could still find some 1111 somewhere in the world.

I am using gmaps.js on my site for getting address from the user and I am relying on gmaps to return lat and log for a valid address.

How do I make sure gmaps.js only returns lat and log when complete address is searched by the user?

incomplete address successful search

Sauchin
  • 333
  • 3
  • 11
  • Without your code your question is next to useless. – Lee Taylor Oct 12 '15 at 03:32
  • I will update my question with the source code. But I didnt think my code was important as if you see on gmaps.js site itself if you search for 1111 address it gives you a successful search – Sauchin Oct 12 '15 at 03:44
  • So, you're saying it works on their site but not on yours? – Lee Taylor Oct 12 '15 at 03:45
  • it works wrongly on their site. Just 1111 is not a valid address but still gmaps.js finds 1111 somewhere in the world and returns its latitude and longitude. – Sauchin Oct 12 '15 at 03:48
  • I would say it is working correctly. It is finding a highway called 1111. – Lee Taylor Oct 12 '15 at 03:51

1 Answers1

1

See GMaps.js is nothing but a plugin for easy handel of Google Maps. It uses google.maps.geocoding to search a address. If address found it marks that. So there is nothing to do in GMaps.js. Google map is able to find that address. please check here.

But from your end you can make diffrent input fields, one for country, one for state, one for town, etc.. as required. Then when user clicks, using regx you can validate. And then you can pass it to Gmas.

Dinesh Patra
  • 1,125
  • 12
  • 23
  • The solution you suggested does make sense even though searching any text is little weird on google maps side. But your solution is definitely the way forward. I agree. – Sauchin Oct 12 '15 at 17:38