Brian Dunning's FileMaker Custom Functions

fmpGoogleMap ( address ; city ; state ; zip ; country )

Webviewer address display using Google Maps

  Average rating: 4.7 (22 votes) Log in to vote

Robert Jackson   Robert Jackson
RJ Plus Consulting
http://rjplusconsulting.tk

Share on Facebook Share on Twitter

  Sample input:
Let (

~address = Contacts::Work Address 1;
~city = Contacts::Work City;
~state = Contacts::Work State;
~zip = Contacts::Work Postal Code;
~country = Contacts::Work Country;
~result =
"https://www.google.com/maps/place/" & 
Case ( IsEmpty (~address) ; "" ; Substitute (~address;" ";"+") )& "+" &
Case ( IsEmpty (~city ); "" ; Substitute (~city;" ";"+") )& "+" & 
Case ( IsEmpty ( ~state) ; "" ; Substitute (~state;" ";"+") )& "+" & 
Case ( IsEmpty (~zip) ; "" ; Substitute (~zip;" ";"+") )& "+" & 
Case ( IsEmpty ( ~country) ; "" ; Substitute (~country; " " ; "+") )
];
~result
)
  Sample output:
https://www.google.com/maps/place/theAddress,+theCity,+theState+theZip,+theCountry

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

//  fmpGooglemap ( address ; city ; state ; zip ; country )

//  Aims:
//  display FileMaker address using Google Maps
//  avoid using Google API
//  avoid using iFrame
//  author Robert Jackson (Scotland)

Let (

~address = address;
~city = city;
~state = state;
~zip = zip;
~country = country;
~result =
"https://www.google.com/maps/place/" & 
Case ( IsEmpty (~address) ; "" ; Substitute (~address;" ";"+") ) & "+" &
Case ( IsEmpty (~city ); "" ; Substitute (~city;" ";"+") ) & "+" & 
Case ( IsEmpty ( ~state) ; "" ; Substitute (~state;" ";"+") ) & "+" & 
Case ( IsEmpty (~zip) ; "" ; Substitute (~zip;" ";"+") ) & "+" & 
Case ( IsEmpty ( ~country) ; "" ; Substitute (~country;"";"+" ) )
];
~result
)

 

 

Comments

Tim Anderson   Tim Anderson, Tim Anderson Group
Jun 12, 2015
Thanks Robert!
 
Robert Jackson   Robert Jackson, Scotland
Jun 12, 2015
tidied up code
 
comment   comment, VR
Jun 15, 2015
What is the difference between:

Case ( IsEmpty (~address) ; "" ; Substitute (~address;" ";"+") )

and:

Substitute (~address;" ";"+")
 
Vyke   Vyke, Washington DC
Jul 6, 2015
If you just do

Substitute(~address;" ";"+"), then, if the address is empty, you will get a +, which will screw up the calc.
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Under construction. Email me your wish list for improvements.