I cannot get the image URL - I tried buildingImage.fields.file.url, and so forth but I keep getting back null. Please see the image attached. buildingImage is a linked image asset. It is returned in the query but I cannot get the URL from the response.
Also, for location, it was being returned as text before then suddenly it’s only returning lat/long. Can I get a string? Or do I have to use GeoCoder?
to answer your question fully, do you mind sharing what type
buildingImage is? If it is a CDAEntry, with a field linking the asset, something like this might be working:
val asset = result.getField<CDAAsset>("media")
val url = asset.url()
Please see that the
media field of an entry links to an asset. if you have an asset, you can ask the
.url() method to get the protocol less url. You would need to add
https: to it to make it a complete url.
To answer your second question: You cannot get the location as a string. The location object is the only one supported. You would need to get the field and then call use it as a map to get its “lat” or “lon” value in Double.
Thanks for your reponse. buildingImage is an Image type:
Much appreciated got the Image working.
For the location, is there an example to convert lat/long into an actual string address (I would have to use Geocoder)?
with the given information I can only wager to think that you are using the android geocoder, please refer to their documentation on how to use it.
You can get the latitude and longitude from the field of the Contentful object given, by using its