Geocode an address

Description

Makes an Ajax callback to a web service to geocode an address. Fill in the latitude and longitude fields in the current record with the information.

Ga

If using Google, an API key is required.

Geocode Settings

Geocode method

Specify the method to use to geocode the address. Google sets a limit on how many addresses can be encoded, but may provide better results than Nominatim.

Address

Specify the field that has the address.

City

Specify the field that has the city.

State/Province

Specify the field that has the state/province.

Zip/Postal Code

(Optional) Specify the field that has the zip/postal code.

Country

(Optional) Specify the field that has the country.

Latitude field

Specify the name of the latitude field. This field will be filled in with the value that is looked up.

Longitude field

Specify the name of the longitude field. This field will be filled in with the value that is looked up.

Return the Latitude and Longitude of an Entered Address

  1. In the UX Builder on the UX Controls page open the 'Data Controls' menu. Click on the [TextBox] option to add a textbox control to the component. Give this textbox the name and label of 'Address'

    Ga2
  2. Click on the [TextBox] option again to add a second textbox control. Name and label the control 'City'

    Ga3
  3. Add a third [TextBox] control to the component. Name and label this control 'State'.

    Ga4
  4. Add a fourth [TextBox] control with the name and label of 'Latitude'

    Ga5
  5. Add a final [TextBox] control to the component with the name and label of 'Longitude'

    Ga6
  6. Highlight the 'State' textbox control in the controls tree. Open the 'Other Controls' menu and click on the [Button] option to add a button under the 'State' textbox.

    Ga7
  7. Highlight the button. In the properties list on the right under 'Button Properties' set the 'Button text' to read 'Find Coordinates'

    Ga8
  8. Scroll down the properties list to the 'Javascript - (Touch, Mouse, Pointer Events)' section. Click the button next to the 'click' property.

    Ga9
  9. Check the 'Action Javascript' radio button and click the 'Add New Action' button.

    Ga10
  10. Type 'geo' into the Filter list, highlight the 'Geocode an address' action in the actions list, and click OK.

    Ga11
  11. In the Geocode an Address properties set the 'Geocode method' to be 'Nominatim'.

    Ga12
  12. Click the dropdown next to the 'Address' property and select the 'Address' textbox.

    Ga13
  13. Click the dropdown next to the 'City' property and select the 'City' textbox.

    Ga14
  14. Click the dropdown next to the 'State/Province' property and select the 'State' textbox.

    Ga15
  15. Click the dropdown next to the 'Latitude' property and select the 'Latitude' textbox.

    Ga16
  16. Click the dropdown next to the 'Longitude' property and select the 'Longitude' textbox. Click OK and Save

    Ga17
  17. Run the component in Live Preview. Fill in the Address, City, and State fields and click the 'Find Coordinates' button.

    Ga18
  18. The latitude and longitude should appear in their respective textbox controls.

    Ga19

Obtain a Latitude and Longitude from an Address in a List

  1. In the UX Builder on the UX Controls page open the 'Data Controls' menu. Click on the [List] option to add a list control to the component.

    Gal
  2. Highlight the list control. In the properties list on the right, scroll down to the 'List Properties' section and click the button next to the 'List properties' property to open the List Builder.

    Gal2
  3. On the List Builder's Data Source pane select 'Static' from the 'Data Source Type' menu.

    Gal3
  4. Click the button next to the 'Static data' property in the Static Data section.

    Gal4
  5. In the Static Choices dialog click on the 'Sample data' button in the lower left corner. From the sample data choices select the 'Name and addresses (big data set)' option and click OK and OK.

    Gal5
  6. In the 'Return Value' section set the 'Return value type' property to be 'Field'

    Gal6
  7. Click the button next to the 'Return field' property and select 'Address' as the return field.

    Gal7
  8. Open the 'List Layout' pane and use the blue > arrow to move the 'ContactName', Address', 'City', and 'Country' fields from the 'Available Fields' list to the 'Columns in List' section. Click OK to close the List Builder.

    Gal8
  9. In the 'Other Controls' menu select the [Button] option to add a button control under the list control.

    Gal9
  10. Open the 'Data Controls' menu click on the [TextBox] option to add a textbox control underneath the button in the controls tree. Name and label the textbox 'Latitude'.

    Gal10
  11. Click on [TextBox] again to add a second textbox to the component. Name and label this textbox 'Longitude'.

    Gal11
  12. Highlight the button control in the controls tree. In the properties list in the 'Button Properties' section set the 'Button text' property to be 'Find Coordinates'.

    Gal13
  13. Scroll down the properties list to the 'Javascript - (Touch, Mouse, Pointer Events)' section. Click the button next to the 'click' property.

    Gal12
  14. In the Edit Click Event dialog select 'Action Javascript' from the radio button options. Click the 'Add New Action' button.

    Gal14
  15. Type 'geo' into the Filter list, highlight the 'Geocode and address' action in the actions list, and click OK.

    Gal15
  16. In the Geocode an Address properties list set the 'Geocode method' property to be 'Nominatim'.

    Gal16
  17. Click the dropdown next to the 'Address' property and select the list you defined, 'list1'.

    Gal17
  18. Click the dropdown next to the 'Latitude field' property and select the 'latitude' textbox from the list of choices.

    Gal18
  19. Set the 'Longitude field' property to be 'longitude'. Click 'OK' and 'Save' to exit.

    Gal19
  20. Run the component in Live Preview. Click on a row in the list and then click the 'Find Coordinates' button. The latitude and longitude values for the address should appear in the Latitude and Longitude textboxes.

    Gal20

See Also