How it works...

If you look at the location change form in the browser, you will see a map shown in a field set, followed by the field set containing the address fields, as shown in the following screenshot:

Under the map, there are two buttons: Locate address and Remove from map.

When you click on the Locate address button, the geocoding is called in order to search for the geographical coordinates of the entered address. The result of the geocoding is one or more addresses, with latitudes and longitudes listed in a nested dictionary format. To see the structure of the nested dictionary in the console of the developer tools, put the following line at the beginning of the autocompleteAddress() function:

console.log(JSON.stringify(results, null, 4)); 

If there is just one result, the missing postal code or other missing address fields are populated, latitude and longitude are filled in, and a marker is put at a specific place on the map. If there are more results, the entire list is shown under the map, with the option to select the correct one, as shown in the following screenshot:

Then, the administrator can move the marker on the map by dragging and dropping. Also, a double-click anywhere on the map will update the geographical coordinates and the marker position.

Finally, if the Remove from map button is clicked, the geographical coordinates are cleaned, and the marker is removed.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.210.143