GoogleMaps v3.0.5

Published by Soliant Consulting on April 13, 2019
Updated on December 10, 2020
Tags: Map
Download Send To Carafe
Download Send To Carafe
Created By: Jeremiah Small
Version: 3.0.5

Windows Tested: Yes
Offline Compatible: No


This bundle requires a valid Google Maps API key. See the reference links for more information.

To integrate this bundle in your own solution, you will need to build an array of markers. The following is and example of a single marker object.

"id": 13,
"title": "Encyclopedia Circle I",
"label": "Commercial",
"color": "blue",
"position": { "lat": 37.516203, "lng": -121.984664 }

You can load a marker object like that from a record in FileMaker with an expression like this

JSONSetElement ( $marker
; [ "id" ; Asset::AssetID ; JSONNumber ]
; [ "" ; Asset::Latitude ; JSONNumber ]
; [ "position.lng" ; Asset::Longitude ; JSONNumber ]
; [ "title" ; Asset::Title ; JSONString ]
; [ "label" ; Asset::Label ; JSONString ]
; [ "color" ; Asset::HexColor ; JSONString ]

With a subscript such as "Asset To Marker JSON" returning a single record in the expected format, you can create a "Map Loader" script which loops over a found set, and assembles your markers. Here is an example "Map Loader" script.

# ====================================================================================================
# Map Loader
# Assumes Asset context
# Loads current Asset found set as a JSON markers collection
If [ Get ( LayoutTableName ) <> "Asset" ]
Exit Script [ Result: "Wrong context" ]
End If
Go to Layout [ "Asset Loading" (Asset) ]

Set Variable [ $i; Value:0 ]
Set Variable [ $markers; Value:"[]" ]
Go to Record/Request/Page [ First ]
Perform Script [ "Asset To Marker JSON" ]
Set Variable [ $marker; Value:Get ( ScriptResult ) ]
If [ JSONGetElement ( $marker ; "" ) <> 0 and JSONGetElement ( $marker ; "position.lng" ) <> 0 ]
Set Variable [ $markers; Value:JSONSetElement ( $markers ; $i ; Get ( ScriptResult ) ; JSONObject ) ]
Set Variable [ $i; Value:$i+1 ]
End If
Go to Record/Request/Page [ Next; Exit after last ]
End Loop

Set Variable [ $parameter; Value:
JSONSetElement( $parameter
; [ "googleApiKey" ; "yourApiKey" ; JSONString ]
; [ "minimumClusterSize" ; 2 ; JSONString ]
; [ "mapData" ; $markers ; JSONArray ]
; [ "fileName" ; Get ( FileName ) ; JSONString ]
; [ "scriptName" ; "Handle Map Pin Click" ; JSONString ]
Go to Layout [ "Map" (Asset) ]
Perform Script [ "Carafe GoogleMaps v3.0.0 Loader"; Parameter: $parameter ]

As you can see in the example "Map Loader" script above, the bundle parameter expects a "fileName" and "scriptName". The bundle will use these to initialize with a click handler. When the user clicks a marker on the map, it will call this script with the marker id as a script parameter, allowing you to respond to the click in any manner you like. For example, you could open a card window and display details about the record the marker represents.

Tip: During development and testing, you can register a project for testing purposes in the Google Cloud Platform Console and use a generic, unrestricted API key, but when you are ready to move your solution into production, you should register a separate Google API project for production and consider securing that according to Google's documented best practices.

This GoogleMaps bundle includes the Marker Cluster extension in the default MetaData. NOTE: You must update the config with your own googleApiKey value before using this bundle.


Name Description Type


aacp29 · June 4, 2020 at 12:51 pm

hello, thank you for this very great job !
I am a (very) beginner with JS and I have two questions :
– with this script, the “labet” (Asset::label) appear under the marker on the map, in black. How to make it bold (or change it’s color or it’s font)?
– with the function “sendToFmp(data)”, I don’t know how to pass back the data to a specific marker. With your example with a dialog box, I can put the data of the active record in the dialog, but it always show the same data, whatever the marker I click. When I hoover a marker I see, in a pop up the “Asset::title”, but only this.
How can I solve this ?

Protonical · July 8, 2020 at 2:51 pm

Nicely executed.
How would I add “zoomlevel” and “map type” through this script?

Jeremiah Small · December 11, 2020 at 11:16 am

Please pop over to the Carafe.FM forums with Carafe questions. See you there?

Leave a Comment