Cluster Maps Continued: Perimeter Search in FileMaker Pro 12

Working on a presentation for a customer that employs the Cluster Maps concept, the request came up about doing perimeter searches—as in ‘How do I see all the related addresses around a specific location?” This ability would aid sales people in the field, cut down on travel etc. A search on Brian Dunning’s very useful Custom Functions collection, I found just what I needed to create these searches.

Download the updated Cluster Maps Demo file here.

Adding Perimeter Search to the Cluster Maps Demo


Clicking ‘Perimeter Search’ button on any address record will result in a perimeter search and display this information on a map in a Web Viewer.

Enter distance


Enter the number of miles you want the perimeter to be surrounding your target address.

Search Result in a new Web Viewer Window


1) Note that the Window title will display the number of found records.
2) The Bounding Box Longitude/Latitude information is displayed here.
3) Google Map search with resulting found records displayed in a cluster.

So how does this work? Start by adding the Custom Function to your database.

Adding a Custom Function


You will need a copy of FileMaker Pro Advanced to access the Custom Functions area in your database. Use the File menu, to select Manage and then Custom Functions… from the popup.

The Custom Function


The Custom Function ‘GeoBox‘ comes from

The function was written by Steve Murray.

It is possible to copy and paste Custom Functions in FileMaker 12 or if you are interested in the details, you can copy and paste the code into the three fields in the Custom Functions definition dialog box.

Details of the Custom Function


Who knows how ‘GeoBox’ works its magic or even if it is totally accurate. It does seem to give the general vicinity, which is probably all you are looking for in most cases.

A Custom Function consists of

1) Function Name
2) Function Parameters and
3) the code to execute using those Parameters.

The Perimeter Search script


A script called “Perimeter Search” has been added to the Cluster Maps database.

Search script using the calculated bounding box from the Custom Function


How the script works:

  1. Display a dialog box with an input field, in this case gPerimeterDistance, a global field defined to hold the distance of the perimeter.
  2. A script variable is set to the bounding box, the result will be four values in a list.
  3. Values from the bounding box are employed in the search, employing the GetValue function.
  4. A new window is opened with the Found Count displayed in the title.
  5. ‘Generate JSON HTML and Display Map’ script is run with a script parameter so the window will display in a Web Viewer.
  6. A Global Variable is set to display the Bounding Box on the layout.

How to use the GeoBox Custom Function


Bonus Tip: Convert search to Kilometers notes in the variable definition rather than messing with the Custom Function.

Related articles:

Creating Google Cluster Maps from FileMaker Pro
Cluster Maps Update – Running URL Scripts in a Web Viewer

Update 2013-06-25 – Updated Demo File. Fixed a bug in the Get Coordinates script. Filtering on the number string and managed to leave out the number 8. I figured 8 doesn’t get used that often and how much could it throw things off?

Also, thanks to reader Henry Rose of MacWizard, discovered that Google returns inconsistent JSON files, so adapted the parsing to narrow the focus on the most accurate Longitude and Latitude numbers of the three returned. Also realized that the Web Viewer on the Map Detail layout was using a calculated address lookup URL rather than a longitude/latitude search. Switched to the more accurate long/lat search. Added a Show on Map button to view single searches in a web browser.

Related Articles

Cluster Maps – Update – Fixed Popup Formatting Bug

7 Responses to “Cluster Maps Continued: Perimeter Search in FileMaker Pro 12”

  1. Thanks Doug. It just keeps getting better and better!!

  2. Has anyone used GeoBoxBounds Custom Function instead of GeoBox for Cluster Maps?

    This function is similar to the GeoBox function by Steve Murray, but it provides more helpful results for search regions that may include a pole or cross the antimeridian (180°/-180° longitude

  3. Cluster maps work perfectly!

    I’ve overcome a slight problem of not being able to drill down to a single marker for duplicate addresses by running a looping script that searches for duplicate addresses and duplicate long/lat, then adusts the co-ordinates slightly.

    I’ve also noticed some of the pins for various addresses are placed “near” an address when Google Maps cannot find an exact match. I’m looking at adding a feature where you could adjust the pin location on the map (within filemaker) for any given record.

    This might be possible by adding an event listener on the map for example a double right click. This would in turn adjust the latitude & longitude fields of the record.
    This should be possible using Google Maps API V3.
    I’m not sure how to implement this I suspect i will have make some adjustments to the Marketcluster JS.


    • Sounds like a good approach, but beyond my capabilities in JavaScript. Check in your area for a good Javascript programmer.

      • There is a cleaner approach to the drilling down to a single marker,where there are multiple markers exist at one address.
        OverlappingMarkerSpiderfier, expands multi-markers with the exact same long / lat. ie once you get down to a certain zoom level individual markers are shown.

        Marketcluster & Spiderfier can be used together, avoiding the need to adjust address co-ordinates for markers at the same address.

        Marketcluster is used to a view markers to a certain zoom level then, spiderfier takes over.


  1. Cluster Maps Continued: Perimeter Search in FileMaker Pro 12 | HomeBase Software | Filemaker Info - July 8, 2013

    […] See on […]

  2. Mapping Directions from FileMaker Pro with Google Maps | HomeBase Software - February 3, 2014

    […] Cluster Maps Continued: Perimeter Search in FileMaker Pro 12 […]

%d bloggers like this: