Locations (latitude and longitude)

Here’s another in the ongoing parade of dumb questions…

OK, I have an address. I ship that address off, via an API Call, to a geocoding service from which I quickly receive latitude and longitude values. Now, I want to stuff those two lovely numbers into an Object Property of type Location so I can show it on a map.

Simple, n’est-ce pas?

But no, I am at a complete loss at how to do it. I’ve only found two ways to populate a Location property:

  1. Put it on a form and have the user fill in Lat & Long
  2. Have it auto-captured in a “Location Capture Field”. This gets the user’s location, which doesn’t help.

This must be simple, but I’ve been at it too long, and I can’t see it. I’m about to write an event processor to see if I can get to the underlying Location structure that way. Please tell me I’m missing something much easier!

Regards,

Randy

The Event processor works, and I found you can also do it with a Composite and a Form dependency.

Both seem a bit convoluted for something that ought to be simple.

Have I missed something easy?

Randy

Morning Randy, the Latitude, Longitude field is a single field in MATS and stores a comma seperated value. When you say the Event Processor works but is convuluted, can you share your approach.

I have done this a few times with a text composite - latitude then comma then longitude - then use the composite wherever you would use a location - if you need to store the location, just a rule to copy the composite into a Lat&long field…

1 Like

Adam & Rich


By “convoluted” I mean, “seems to be a lot more work than it ought to be!”


First, I added Latitude and Longitude fields to my base object. Then I created an Event Action that is triggered whenever the base object is modified and both Lat & Long are non-empty. The Action grabs the Lat & Long fields, concatenates them with a comma in the middle and stuffs it into the Location field.


The rule fires more often than it needs to, but this is a sandbox application so I’m not too worried about it. For a production app I’d have it fire only when one or the other or both of the Lat/Long fields is changed.


I also found the solution that Rich describes. This also requires separate Lat & Long fields as well as a composite that concatenates them and add the requisite comma. It also works, and it is simpler that the Event Action, but still seems kludgey to me.


It appears that the norm for geocoding is to return Lat & Long separately; it would be nice if Mats (still working on getting comfortable with “Liberty Create”) handled them more elegantly.


Regards,

Randy