In my website, I allow members to use the Google Maps integration I have in order to search and select their home address.
I'm trying to figure out a way in which I co开发者_如何学JAVAuld enforce a full address selection only.
At the moment, the member sees a search box and a map, once he inputs a search the result is shown on the map and he can choose 'This is my address'.
My current issue is that a lot of people selects 'Fairfax, USA' for example, rather than the exact address.
I know this is a lot about disciplining the members, but is there any technical way of preventing them from choosing a 'too general' address?
Thanks,
I haven't worked much with the google maps api, but you can send their input to the web service api, and load the first given result, and ask if that's their address, and only accept addresses from the api...
Edit: (Based on our talk in the comments) When you ask the api to find an address it tells you what kind of location it returns for you, just simply check for "type" "street_address" on line four of your result like in this api request.
精彩评论