Copy link to clipboard
Copied
Hi Everyone,
I have a field that asks the user for a full address to be typed in. I'd like to add a button that, when clicked, launches the default browser and performs a Google Maps search of that address. Or, at the very least, a Google search of that address.
Is there a relatively easy script that can be applied to that button?
Like this:
app.launchURL("https://www.google.com/maps/search/" + this.getField("Full Address").valueAsString);
Just to clarify: This will open the URL in the default browser. It will NOT make the results accessible to your code or allow you to embed them in your PDF or anything like that.
Copy link to clipboard
Copied
The short answer is NO. Acrobat form scripts have no mechanism for receiving and interpreting results from a web API.
But, there are a couple of other options. If you could install an Acrobat automation script on to the user's system, then that script could execute SOAP and regular HTTP request. If this is not possible, then the other option is to write a server script that does the api calls to google maps. This scirpt would get the form submit from the PDF, interact with google, and return results that the PDF form can use.
Copy link to clipboard
Copied
Thanks Thom. Very helpful. What about this as a workaround: using JavaScript to open a browser tab that includes the content provided in that field appended to a URL?
Copy link to clipboard
Copied
You can do it, actually, by using this URL:
Copy link to clipboard
Copied
Thanks for the note. How would I append the parameter that the user types in to that field to the "YourSearchQuery" however? I know I can't hardcode it using the Action of opening a web link, so I'm assuming I have to use JavaScript.
Copy link to clipboard
Copied
Like this:
app.launchURL("https://www.google.com/maps/search/" + this.getField("Full Address").valueAsString);
Just to clarify: This will open the URL in the default browser. It will NOT make the results accessible to your code or allow you to embed them in your PDF or anything like that.
Copy link to clipboard
Copied
Brilliant. Thank you so much. Worked like a charm.