« MBS FileMaker Plugin,… | Home | Printing a WebViewer … »

Use MapKit to validate addresses

Recently a client asked if we could help on entering addresses. Like to fix typos, lookup zip codes or split addresses into fields like for street name, house number and city. We got an idea and made a new sample file for you to validate address with MapKit.

We use the CLGeocoder functions to geocode the address. Once done, we can inspect the result and query the various parts of the response. This includes the thoroughfare (aka street) and the subThoroughfare (house number). We can then fill the fields in our database and get the address from the user parsed.

 

Here is the sample script form our sample file included with MBS FileMaker Plugin in v14.1 or newer:

 

Set Variable [ $geocoder ; Value: MBS( "CLGeocoder.GeocodeAddressString"; Validate Address::Input; 1) ] 

If [ MBS("IsError") ] 

Show Custom Dialog [ "Failed to locate address" ; $geocoder ] 

Else If [ MBS( "CLGeocoder.PlacemarkCount"; $Geocoder ) = 0 ] 

Show Custom Dialog [ "No place found." ] 

Else

Set Variable [ $streetNumber ; Value: MBS( "CLGeocoder.PlacemarkValue"; $Geocoder; 0; "subThoroughfare") ] 

Set Field [ Validate Address::Address ; MBS( "CLGeocoder.PlacemarkValue"; $Geocoder; 0; "Address") ] 

Set Field [ Validate Address::PostalCode ; MBS( "CLGeocoder.PlacemarkValue"; $Geocoder; 0; "postalCode") ] 

Set Field [ Validate Address::City ; MBS( "CLGeocoder.PlacemarkValue"; $Geocoder; 0; "locality") ] 

Set Field [ Validate Address::Street ; MBS( "CLGeocoder.PlacemarkValue"; $Geocoder; 0; "thoroughfare") & If ( Length ( $streetNumber ) > 0; " " & $streetNumber; "" ) ] 

Set Field [ Validate Address::Country ; MBS( "CLGeocoder.PlacemarkValue"; $Geocoder; 0; "Country") ] 

Set Field [ Validate Address::JSON ; MBS("JSON.Colorize"; MBS( "CLGeocoder.JSON"; $Geocoder)) ] 

End If

Set Variable [ $r ; Value: MBS( "CLGeocoder.Close"; $Geocoder ) ] 

 

Please try and let us know how well it works.

Claris FileMaker Plugin
15 02 24 - 10:39