Google offers a plethora of APIs for integrating various Maps features into custom solutions, including polygons. In Google Maps, a polygon is defined by a series of connected coordinates that form a closed loop. They can be used to define the boundaries of a lake, city, or forest, for example, and to show the distribution of features across different regions on the map. In this article, we'll discuss how to use the Google Maps JavaScript API polygons feature to display locations and regions on a virtual map embedded in your FileMaker solution.Â
API Setup
Getting your API key is free and easy. The first step is to create a project in the Google Developers Console if you don't already have one.
Once you have created the project, you will need to enable the Google Maps JavaScript API and set up API credentials. Once you have an API key, paste it into the example FileMaker solution.
Storing and Restoring Polygons
A FileMaker record needs to be created for each polygon drawn on the map. This allows the polygon to be recreated when the map is refreshed or when used in a different layout within the FileMaker solution. To achieve this, we retrieve the properties of the polygon object and send them to FileMaker.PerformScript() function. This logic is implemented in a listener function that runs when the user completes drawing a polygon on the map.
We use a handler script in FileMaker to take the polygon properties, create a FileMaker record, and assign those properties to a field.
We need a script and a JavaScript function to restore polygons stored in FileMaker. The FileMaker script creates a list of polygon properties through a Cartesian relationship and calls an associated function using the Perform JavaScript in Web Viewer script step.
Finally, the JavaScript function takes the list of polygon properties and adds them to the map.
Conclusion
Using Google Maps polygons in conjunction with your FileMaker solutions enables you to display useful, dynamic geographic information with simple FileMaker scripts and a few lines of code.
Explore our integration options to see what else is possible for your FileMaker setup. If you have any questions or would like to discuss a Google Maps integration for your FileMaker solution, please contact DB Services.
Did you know we are an authorized reseller for Claris FileMaker Licensing?
Contact us to discuss upgrading your Claris FileMaker software.
Download the FileMaker Google Maps Polygon Integration File
Please complete the form below to download your FREE FileMaker file.