I'm trying to find Opportunity records with an address within X amount of miles from an entered location. I'm using the lightning-input-address and passing the value to an Apex class and am getting this error - "AuraEnabled methods do not support parameter type of System.Address ". Is there any workaround to this?

LWC snippet:

     class="location" value={location}
     address-label="Address" street-label="Street"
     city-label="City" country-label="Country"
     province-label="State" postal-code-label="Zip/ Postal Code"
     onchange={handleAddressChange} address-lookup-placeholder = "Search Address..."

@wire(getAddy, {location: '$location', allData: '$allData', distance: '$distance'})
wiredAccounts({ error, data }) {...}


public static List<Opportunity> getLocation(Address location, List<Opportunity> allData, Integer distance) {
  //  Address addr = location;
    Double lat = location.latitude;
    Double lon = location.longitude;
    List<Opportunity> oppList = new List<Opportunity>([SELECT ID, Name FROM Opportunity WHERE DISTANCE(Hospital_Location__c, GEOLOCATION(:lat,:lon), 'mi') < :distance AND Id IN :allData]);
    return oppList;

2 Answers 2


You should be able to just define a custom class to use instead.

public class LatLong
    @AuraEnabled public Decimal latitude { get; set; }
    @AuraEnabled public Decimal longitude { get; set; }

Change your parameter type from Address to LatLong, and it should fix the error you received. You can make it an inner class to your controller, or a top level class if you believe you may use this approach in multiple places.

  • Apologies if I'm missing something but how is the "location" param passed? It's a System.Address type. Commented Dec 15, 2022 at 17:35
  • What I'm saying is you should simply change that type to this custom type, which you should define.
    – Adrian Larson
    Commented Dec 15, 2022 at 19:52

I am not sure if the answer I will provide will actually get you a solution.

In your handleAddressChange you can capture the additional details of the address and then you can pass these into your Apex class.

So you can see below:

handleAddressChange(event) {

However I think you are actually after a latitude and longitude and I do not think that the lightning-input-address actually provides this.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .