Skip to content

Instantly share code, notes, and snippets.

@mburnette
Last active August 3, 2023 10:43
Show Gist options
  • Save mburnette/0ac773a857351a98f57d72ded6207de9 to your computer and use it in GitHub Desktop.
Save mburnette/0ac773a857351a98f57d72ded6207de9 to your computer and use it in GitHub Desktop.
Lat/Lon coordinates in fields from WS Form map field
/*
* This assumes a few things:
* - You have WS Form installed and have a form with a Google Maps field
* - You have the Google Maps API key configured
* - You know how to set up a conditional action in WS Form
*
* Create a new Conditional Action in WS Form. Set the following:
* IF [Google Map field] is not blank
* THEN Form > Run Javascript
* ELSE blank
*
* Paste the following code in the javascript code area.
*/
var coords = `#field(110)`.split(","); // replace #field(110) with your Google Maps field ID
document.getElementById('wsf-1-field-118').value = coords[0]; // replace `wsf-1-field-118` with your latitude field ID
document.getElementById('wsf-1-field-119').value = coords[1]; // replace `wsf-1-field-119` with your longitude field ID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment