When I run a code snippet in console, it doesnt give any error but when I use it inside an apex method, I keep getting this error: Method does not exist or incorrect signature: void newInstance(Decimal, Decimal) from the type String. Both the lines in first code have same error. geoLatitude and geoLatitude are defined initilly.
Relevant Code:
for(AccountContactRelation ac : accConMap){
Location locAcc = Location.newInstance(ac.Account.BillingLatitude, ac.Account.BillingLongitude);
Location locZip = Location.newInstance(geoLatitude, geoLongitude);
acConDistanceMap.put(ac.Id, Location.getDistance(locZip, locAcc, 'mi') );
}
But when i put similar code in console, it works and gives me location.
AccountContactRelation acc = [SELECT Id, Account.BillingLatitude, Account.BillingLongitude FROM AccountContactRelation Where AccountId = '001f000001POxdiAAD' LIMIT 1];
Location locAcc = Location.newInstance(acc.Account.BillingLatitude, acc.Account.BillingLongitude);
System.debug(locAcc);
What am I missing?