The Original Filemaker Community - Forum
Developer Questions & Answers for over 22 years

FileMaker Geocoding with Open Street Maps

In this post submitted by Jeroen Aarts of Clickworks, Jeroen demonstrates using Open Street Maps as a Google Maps alternative…

As an alternative for the Google Maps API, you might consider using Open Street Maps (OSM). OSM has a very simple, clever geocoding service called Nominatim. Use FileMaker\’s Insert From URL script step, choose JSON as return format and parse latitude (lat) and longitude (lon).

As an example, have a look at the details from our Antwerp office: This returns the following result: [{\”place_id\”:\”175614111\”,\“licence\”:\”Data © OpenStreetMap contributors, ODbL 1.0. https:\\/\\/\\/copyright\”,\”osm_type\”:\”way\”,\”osm_id\”:\”511761021\”,\”boundingbox\”:[\”51.2036036\”,\”51.2037706\”,\”4.4328532\”,\”4.4330846\”],\”lat\”:\”51.20368615\”,\”lon\”:\”4.4329703913766\”,\”display_name\”:\”36, Cogels-Osylei, Berchem, Antwerpen, Vlaanderen, 2600, België\”,\”class\”:\”historic\“,\”type\”:\”building\”,\”importance\”:0.62025}]

If you store the result in a variable $result, use these function calls in FileMaker to parse the latitude and longitude: Set Variable [ $lat ; Value: JSONGetElement ( \”[0]lat\” ) ] Set Variable [ $lon ; Value: JSONGetElement ( \”[0]lon\” ) ] Please be aware that the returned JSON object is actually an array which may consist of more than 1 element. In the above example we are parsing the lat and lon elements from the first array item – remember that the JSONGetElement() function is 0-based when querying arrays. The Usage Policy is much more flexible than that of the Google Maps API\’s. Of course, if you are using the OSM service, respect terms of service and copyright.

Reverse geocoding: getting a street addressYou can reverse geocode as well, that is, retrieving a street address from longitudes and latitudes. As an example, from this query: We get this result: {\"place_id\":\"175614111\",\"licence\":\"Data © OpenStreetMap contributors, ODbL 1.0. https:\\/\\/\\/copyright\",\"osm_type\":\"way\",\"osm_id\":\"511761021\",\"lat\":\"51.20368615\",\"lon\":\"4.4329703913766\",\"display_name\":\"36, Cogels-Osylei, Berchem, Antwerpen, Vlaanderen, 2600, België\",\"address\":{\"house_number\":\"36\",\"road\":\"Cogels-Osylei\",\"city_district\":\"Berchem\",\"city\":\"Antwerpen\",\"county\":\"Antwerpen\",\"state\":\"Vlaanderen\",\"postcode\":\"2600\",\"country\":\"België\",\"country_code\":\"be\"},\"boundingbox\":[\"51.2036036\",\"51.2037706\",\"4.4328532\",\"4.4330846\"]}

See more great FileMaker Blogs from our friends at ClickWorks!