function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
CMielczarskiCMielczarski 

Issue with setting lightning:map center attribute in Summer 19 preview

Wondering if anyone else has come across this and may have a solution/suggestion. I have a customized mapping component our service people are using, and while preparing to work on something else for their interface in our sandbox I noticed that the map was throwing an error in the console when trying to set the center position: "InvalidValueError: setPosition: not a LatLng or LatLngLiteral: in property lng: not a number"
Now this is working as intended in our live environment, and I haven't done anything to this component yet. The only difference between the environments is that our sandbox was recently put on the Summer '19 preview, and I can't seem to find anything in the release notes where the specifications may have changed, but I'm at a loss for how to correct this. Regardless of how I try to set that Center attribute it throws that same error, even if I bypass the dynamic setting and hard-code a numerical value into the lat and lng attributes that I know is valid.
Here's the helper method that was previously setting the center after it called to the server to make a query:
 
searchNearAccounts : function(component, event, helper){
    component.set("v.locationDetails", null);
    var streetAddr;
    var cityAddr;
    var stateAddr;
    var zipAddr;
    var geolocation;
    var accType = component.get("v.facilityType", "v.value");
    console.log('Chosen facility type: ' + accType);
    var initialProcess = component.get("v.callingObject", "v.value");
    console.log("callingObject for Markers: " + initialProcess);
    if(initialProcess === 'contact'){
        streetAddr = component.find("conStreet").get("v.value");
        cityAddr = component.find("conCity").get("v.value");
        stateAddr = component.find("conState").get("v.value");
        zipAddr = component.find("conZip").get("v.value");
        geolocation = component.get("v.contactGeo", "v.value");
        }
    else if(initialProcess === 'patient'){
        streetAddr = component.find("ptStreet").get("v.value");
        cityAddr = component.find("ptCity").get("v.value");
        stateAddr = component.find("ptState").get("v.value");
        zipAddr = component.find("ptZip").get("v.value");
        geolocation = component.get("v.patientGeo", "v.value");
        }
        else{
            console.log('Addressing Error');    
            }

    console.log('streetAddr: ' + streetAddr);
    console.log('cityAddr: ' + cityAddr);
    console.log('stateAddr: ' + stateAddr);
    console.log('zipAddr: ' + zipAddr);
    console.log('geolocation: ' + geolocation);
    if(geolocation !== undefined){
        var action = component.get("c.getNearByAccounts");
        return new Promise(function(resolve, reject){
            action.setParams({
                "city" : cityAddr,
                "state" : stateAddr,
                "zipCode" : zipAddr,
                "loc" : geolocation,
                "accType" : accType
            });
            action.setCallback(this, function(a){
                var response = a.getReturnValue();
                var state = a.getState();
                console.log('Populate Account Markers',state);
                if(component.isValid() && state !== "SUCCESS"){
                    console.log("Error in fetching Account Markers.");
                    return;
                }
                else{
                    try{
                    var repList = response;
                        if(response !== null && response !== undefined){
                            component.set("v.locationDetails", repList);
                            var mapComponent = component.find('mapComponent');
                            if(mapComponent && mapContainer !== undefined){
                                mapComponent.destroy();
                                }
                            var mapContainer = component.find('mapContainer');
                                if(mapContainer){
                                    mapContainer.set("v.body", "");
                                    }
                            var mapBody = mapContainer.get("v.body");

                            var center;
                           console.log(); 
                        if(cityAddr !== undefined && zipAddr !== undefined && stateAddr !== undefined && stateAddr.length === 2){
                            if(streetAddr === undefined){
                                streetAddr = '123 St';
                                }
                            center = {
                                location:
                                        {
                                        City: cityAddr,
                                        Country: 'USA',
                                        PostalCode: zipAddr,
                                        State: stateAddr,
                                        Street: streetAddr
                                        }
                                    };
                            }
                        else{
                            console.log('lat: ' + parseFloat(geolocation.split(",")[0]));
                            console.log('lng: ' + parseFloat(geolocation.split(",")[1]));
                            center = 
                                    {
                                    location: {
                                            'Latitude': geolocation.split(",")[0],
                                            'Longitude': geolocation.split(",")[1]
                                            }
                                    };
                            }
                        console.log('Map center: ' + center);
                        if(center != null && center != undefined){    
                    $A.createComponent(
                        "lightning:map",
                        {
                            "aura:id" : 'mapComponent',
                            "mapMarkers" : repList,
                            "zoomLevel" : 8,
                            "center" : center,
                            "markersTitle" : "Accounts"
                        },
                        function(lightningMap){
                            mapBody.push(lightningMap);
                            mapContainer.set("v.body", mapBody);
                        }
                    );
                    component.set("v.facilitySelectLocked", false);

                    var listTemp = [];
                    listTemp.push('--Make a Selection--');

                    for(var i = 0; i < response.length; i++){
                        if(response[i].contentCount > 0){
                            listTemp.push(response[i].title + ' - ' + response[i].accId);
                            }
                        }
                    component.set("v.selAccounts", listTemp);
                    if(listTemp.length > 0){
                        component.set("v.allowContentSearch", true);
                        }
                    else{
                        component.set("v.allowContentSearch", false);
                        }
                    }
                    }
                    }
                    catch(err){
                        return;
                    }
                    resolve("Resolved");
                }
            });
            $A.enqueueAction(action);
        });
    }
},

And here is the server-side method(s) involved with getting my mapping locations:
 
@AuraEnabled(cacheable=true) 
public static List<LocationMap> getNearByAccounts(String city, String state, String zipCode, string loc, string accType){
    List<LocationMap> result = new List<LocationMap>();
    Integer maxDistance = 100;
    system.debug('city: ' + city);
    system.debug('state: ' + state);
    system.debug('zipCode: ' + zipCode);
    system.debug('location: ' + loc);
    system.debug('Facility Type: ' + accType);

    string latitude = '';
    string longitude = '';
    try{
        latitude = loc.substringBefore(',').trim();
        longitude = loc.substringAfter(',').trim();

        decimal lat = decimal.valueOf(latitude);
        decimal lon = decimal.valueOf(longitude);

        system.debug('latitude: ' + latitude);
        system.debug('longitude: ' + longitude);

        Location loc1 = Location.newInstance(lat, lon);

        String strQueryString;
        string status = 'Active';
        strQueryString = 'SELECT Name, Central_Intake_Email__c, Facility_Number__c, ShippingStreet, Shipping_Geolocation__Latitude__s, Shipping_Geolocation__Longitude__s, ShippingCity, ShippingState, ShippingCountry, Type, Phone, ShippingPostalCode FROM Account WHERE RecordTypeId = : accountCenter AND Type != null AND Status__c=: status';
        if(accType != '' && accType != '--None--' && accType != null){
            strQueryString += ' AND Type =: accType';
            }
        if(city != '' || zipCode != '' ){
            strQueryString += ' AND DISTANCE(Shipping_Geolocation__c, GEOLOCATION(' + latitude + ',' + longitude + '), \'mi\') < '+ maxDistance+
                                ' ORDER BY DISTANCE(Shipping_Geolocation__c, GEOLOCATION(' + latitude + ',' + longitude + '), \'mi\') limit 250';
            }
        else if(state != ''){     
            strQueryString +=' AND ShippingState = : state ORDER BY DISTANCE(Shipping_Geolocation__c, GEOLOCATION(' + latitude + ',' + longitude + '), \'mi\') ASC limit 250';
            }
        system.debug('query: ' + strQueryString);
        List<Account> accounts = new List<Account>();
        if(!test.isRunningTest()){
            accounts = Database.query(strQueryString);
            }
        else{
            accounts = AA_UtilityClass.getTestList;
            }   
        system.debug('Accounts: ' + accounts);

        list<ID> accIDs = new list<ID>();
        for(Account a: accounts){
            accIDs.add(a.ID);
            }

            map<ID, Integer> accContentMap = new map<ID, Integer>();

            for(AggregateResult agrA :  [SELECT COUNT(Id) countIds, 
                            Center__c accID
                            FROM ContentVersion 
                            WHERE Center__c IN:accIDs 
                            AND IsLatest = true 
                            AND  FileType In ('MP4','PDF')
                            Group By Center__c 
                            ]){
                            accContentMap.put(string.valueOf(agrA.get('accID')), integer.valueOf(agrA.get('countIds')));                                    
                            }

         for(Account acc :accounts){
            GeoLocation geoInfo = new GeoLocation();
            geoInfo.street = acc.ShippingStreet;
            geoInfo.postalCode = acc.ShippingPostalCode;
            geoInfo.city = acc.ShippingCity;
            geoInfo.state = acc.ShippingState;
            geoInfo.country = 'USA';
            geoInfo.latitude = acc.Shipping_Geolocation__Latitude__s;
            geoInfo.longitude = acc.Shipping_Geolocation__Longitude__s;
            LocationMap locDetail = new LocationMap();
            Location loc2 = Location.newInstance(acc.Shipping_Geolocation__Latitude__s, acc.Shipping_Geolocation__Longitude__s);
            decimal dist = Location.getDistance(loc1, loc2, 'mi');
            dist = dist.setScale(2);
            locDetail.icon = 'standard:account'; 
            locDetail.title = acc.Name  + ': ' + acc.Facility_Number__c;
            locDetail.description = acc.ShippingStreet + ' ' + 
                                    acc.ShippingCity + ', ' + acc.ShippingState + ' ' + acc.ShippingPostalCode;
            locDetail.street = acc.ShippingStreet;
            locDetail.city = acc.ShippingCity;
            locDetail.state = acc.ShippingState;
            locDetail.zip = acc.ShippingPostalCode;
            locDetail.dist = dist  + ' mi';
            locDetail.accType = acc.Type;                                       
            if(acc.Phone != null){
                locDetail.phone = acc.Phone;
                }
            locDetail.contentCount = 0;
            if(accContentMap.get(acc.ID) != null){
                locDetail.contentCount = accContentMap.get(acc.ID);
                }
            locDetail.accId = acc.Id;    

            locDetail.location = geoInfo;
            result.add(locDetail);
                }
        system.debug('mapPips: ' + result);
        return result;
        }
    catch(Exception e){
        system.debug('Error: ' + e.getMessage() + ' Line: ' + e.getLineNumber());
        return null;
        }   
    }    

public class LocationMap{
    @AuraEnabled 
    public String icon  {get;set;} 
    @AuraEnabled 
    public String title {get;set;} 
    @AuraEnabled
    public String description   {get;set;}
    @AuraEnabled
    public String street    {get;set;}
    @AuraEnabled
    public String city  {get;set;}
    @AuraEnabled
    public String state {get;set;}
    @AuraEnabled
    public String zip   {get;set;}
    @AuraEnabled
    public String phone {get;set;}
    @AuraEnabled
    public String dist  {get;set;} 
    @AuraEnabled 
    public GeoLocation location {get;set;}
    @AuraEnabled 
    public integer contentCount {get;set;}
    @AuraEnabled
    public string accId {get;set;}
    @AuraEnabled
    public string accType   {get;set;} 
    }

public class GeoLocation{
    @AuraEnabled 
    public String Street    {get;set;}
    @AuraEnabled 
    public String PostalCode    {get;set;}
    @AuraEnabled 
    public String City  {get;set;}
    @AuraEnabled 
    public String State {get;set;}
    @AuraEnabled 
    public String country   {get;set;}
    @AuraEnabled 
    public decimal Latitude {get;set;}
    @AuraEnabled 
    public decimal Longitude    {get;set;}
    }

My map pips work as intended and end up where they're supposed to be, the only problem is that the map starts centered in the middle of the Pacific thanks to that InvalidValueError, so if anyone has any suggestions on how best to address that would be appreciated.