In this module, you use a standard event to interact with the Salesforce1 application. When a user clicks a marker on the map, you load the default Salesforce1 details view for the selected account.
In the developer console, open the AccountMap component.
Click CONTROLLER (upper right corner in the code editor).
In the accountsLoaded function, add a click event handler to markers as follows:
L.marker(latLng, {account: account}).addTo(map).on('click', function(event) {
helper.navigateToDetailsView(event.target.options.account.Id);
});
Click File > Save to save the controller.
Click HELPER (upper right corner in the code editor), and define a new navigateToDetailsView function implemented as follows:
({
navigateToDetailsView : function(accountId) {
var event = $A.get("e.force:navigateToSObject");
event.setParams({
"recordId": accountId
});
event.fire();
}
})
Click File > Save to save the file.
Go back to the Salesforce1 app and reload Account Locator from the menu to see the changes. Click a marker on the map: the Salesforce1 details view for the selected account should load automatically.