I have a front-end form where, among other things, the user can enter their address.
Currently, I have fields for street, house number, zip code, city, and a Google Map field.
I would like to give the user the option of not having to repeat himself, i.e. not having to enter his address a second time to pinpoint his location on the map.
Instead, I’m working on a function to feed the data from the address fields to the map. The ideal situation would be for the map to search for address options so the user would only have to click on the correct one (as is the case while entering information into the map).
The function I wrote is as follows:
var street = "",
house = "",
zip = "",
city = "";
$('#form-street').focusout(function() {
street = $('#form-street input')[0].value;
$('#form-map input')[0].value = street + " " + house + " " + zip + " " + city;
});
$('#form-city').focusout(function() {
city = $('#form-city input')[0].value;
$('#form-map input')[0].value = street + " " + house + " " + zip + " " + city;
});
This actually works, it just has two problems: