Skip to content

Instantly share code, notes, and snippets.

@sfmishra
Created March 23, 2019 20:07
Show Gist options
  • Save sfmishra/ec9b18e96d51e7f0da862d0d9d76d6a2 to your computer and use it in GitHub Desktop.
Save sfmishra/ec9b18e96d51e7f0da862d0d9d76d6a2 to your computer and use it in GitHub Desktop.
({
initHelper : function(component, event, helper) {
helper.utilSetMarkers(component, event, helper);
},
utilSetMarkers: function(component, event, helper){
//Variables declared with the let keyword can have Block Scope.
//{ let x = 2; } x cannot be uset outside the block
var action = component.get("c.getAllTowers");
action.setCallback(this, function(response){
var state = response.getState();
if(state == 'SUCCESS') {
const data = response.getReturnValue();
const dataSize = data.length;
const markers = [];
for(let index = 0; index < dataSize-1; index++) {
const Tower = data[index];
markers.push({
'location': {
'Latitude' : Tower.Location__Latitude__s,
'Longitude' : Tower.Location__Longitude__s
},
'icon': 'utility:Tower',
'title' : Tower.Name,
'description' : Tower.Name + ' Tower Location at ' + Tower.State__r.Name
});
}
component.set("v.markersTitle", "Out and About Communications Tower Locations");
component.set("v.mapMarkers", markers);
}
});
$A.enqueueAction(action);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment