Google Maps from Filemaker

This Filemaker custom function takes an address and returns text formatted as a URL to display a Google Map in Filemaker. This can be used to open a URL or Web Viewer window.

Street can be on multiple lines, and can contain unit numbers etc. Any extra text will be removed.

State can be abbreviated or full.

If country field is empty, it will default to the country set in DefaultCountry variable.

/*

GoogleMap ( Street; Suburb; State; Zip; Country )

Takes an address and returns text formatted as a URL to display a Google Map. This can be used to open a URL or Web Viewer window.

Street can be on multiple lines, and can contain unit numbers etc.
State can be abbreviated or full

If country field is empty, it will default to the country set in DefaultCountry variable.

*/

Let ( [

DefaultCountry = "Australia";

// Remove extra lines
StreetNameTemp = If ( PatternCount (Street;"¶") > 0 and Position(Street;"¶";1;1)< Length (Street);Right ( Street ; Length ( Street ) - Position ( Street ; "¶" ; 1 ; 1 ));Street);

// Remove any unwanted text before the street number
StreetNameTemp = Case(
PatternCount(StreetNameTemp;",")>0;Right(StreetNameTemp;Length(StreetNameTemp) - Position (StreetNameTemp; "," ;1 ;1 ));
PatternCount(StreetNameTemp;"/") > 0; Right(StreetNameTemp;Length(StreetNameTemp) - Position(StreetNameTemp;"/";1;1));

LeftWords(StreetNameTemp;1)="Unit" or LeftWords ( StreetNameTemp ; 1 ) = "Flat" or LeftWords ( StreetNameTemp ; 1 ) = "Level" or LeftWords ( StreetNameTemp ; 1 ) = "Suite";Right(StreetNameTemp;Length(StreetNameTemp) - Position(StreetNameTemp;" ";1;2));StreetNameTemp);

StreetName = Trim(RightWords (StreetNameTemp; WordCount ( StreetNameTemp )-1 ));
StreetName = Substitute ( StreetName ; " " ; "+" );
StreetNumber = LeftWords (StreetNameTemp;1 )

];

“http://www.google.com/maps?q=” & StreetNumber & “+” & StreetName & “+” & Suburb & “+” & State & “+” & Zip & “+” & If ( IsEmpty(Country); DefaultCountry; country)
)

This entry was posted in Blog. Bookmark the permalink.

Comments are closed.