« MBS FileMaker Plugin,… | Home | Automate login to Fil… »

Core Location Geocoder with JSON


When we implemented CLGeocoder functions in year 2014, there was not much JSON in use. Nowadays a lot of FileMaker developers deal with JSON data, so why not add more JSON functions to MBS Plugin?

We got a refreshment for our CLGeocoder functions today. For next plugin we first add a wait parameter to CLGeocoder.GeocodeAddressString and CLGeocoder.ReverseGeocodeLocation functions. If wait is 1, the plugin waits a bit until the geocoder is done. Just convenient to avoid having the loop to wait in FileMaker scripts.

Second, we add a CLGeocoder.JSON function to return the data as JSON. This is one big JSON which encodes all the details including status variables, error details and the list of place marks found. For each place mark you get the location, region and address properties.

We can now query address in one Let statement, check status and return the result as JSON:

Let ( [
  Address = "Berlin, Germany";
  // run query and wait a bit
  g = MBS( "CLGeocoder.GeocodeAddressString"; Address; 1 );
  e = MBS("IsError");
  // query JSON if we got something
  r = If (e = 0; MBS( "CLGeocoder.JSON"; g ); g);
  // free resources
  f = If (e = 0; MBS( "CLGeocoder.Close"; g ); 0)
]; r )

Similar let statement for the other way around:

Let ( [
  latitude = 52.517631899999998;
  longitude = 13.4096574;
  // run query and wait a bit
  g = MBS( "CLGeocoder.ReverseGeocodeLocation"; latitude; longitude; 1 );
  e = MBS("IsError");
  // query JSON if we got something
  r = If (e = 0; MBS( "CLGeocoder.JSON"; g ); g);
  // free resources
  f = If (e = 0; MBS( "CLGeocoder.Close"; g ); 0)
]; r )

We add this for next release for your convenience. Please do not hesitate to contact us in case of questions.
12 02 20 - 10:15