• Arumugam K
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hello,

I have requirement that want to fetch data from controller to javascript and want to form a Map in javascript but I'm not able to form a map in javascript. Any way to solve this.
here is my current code which is not getting output:
var latLangAddMap = new Map();
var existingLat;
var existingLong;
var existingLatLng;
var existingAddress;


for (var i=0; i<result.length; i++) {
    console.log('result i'+ JSON.stringify(result[i]));
     var id = result[i].Id;
     var name = result[i].Name;
     existingLat = result[i].Location_Name__Latitude__s;
     existingLong = result[i].Location_Name__Longitude__s;
     existingAddress = result[i].Address__c;
     existingLatLng = existingLat + ',' + existingLong;
     //console.log('existingLatLng=>  '+existingLatLng);
     if(existingAddress != '' || existingAddress != null){
        latLangAddMap.set(existingLatLng,'');
     }else{
         latLangAddMap.set(existingLatLng,existingAddress);
      }
       console.log('latLangAddMap=> '+latLangAddMap);
    }

Please have a look and let me any other way to form a map in js.
You can also test the output on this link:

https://www.javascripture.com/Map


Welcome to your suggestions!
Thanks,
Nilesh