Ability to show Latitude / Longitude coordinates in an Address field
Even if you can define an address by input Latitude / Longitude then you can not show these values in any record view bc only the text address is showed (or the map).
Hi, even if we know each other in person, for the benefit of everyone here is how I am doing it:
1) If you are only interested in the coordinates and you do not need the address you can uncheck the "geocoding" feature in the field options and then you can create a text field with the conditional rule that for each records sets it equal as the address. You will have the text with the coordinates
2) If you want both, keep the geocoding and do the same as above. You will see in this field both the geocoded address as well as the latitude / longitude
3) If you have to manage the lat and log as separate fields, you can do it only through the API. I am setting the log / lat every time I do an update or a create on that record. Below an example:
$(document).on('knack-record-create.view_195', function(event, view, record) {
api_url = 'https://api.knack.com/v1/pages/scene_xx/views/view_xx/records/';
api_url += record.id;
data = {
"field_xx": {
"longitude" : record.field_yy_raw.longitude,
"latitude" : record.field_yy_raw.latitude
},
"field_239":record.field_yy_raw.latitude,
"field_240":record.field_yy_raw.longitude
};
headers = {
'X-Knack-Application-ID': 'xxxxxxxxxx',
'X-Knack-REST-API-Key': 'knack',
'Authorization': Knack.getUserToken(),
'Content-Type': 'application/json'
};
$.ajax({
url: api_url,
headers: headers,
type: 'PUT',
data: JSON.stringify(data),
}).done();
});
1 Like