• Nilima Kumari
  • NEWBIE
  • 10 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 3
    Replies
Hello Experts

I am new to the Visualforce, 
i am working on a requirement where live Location has to be tracked on the VF page Google maps Including Markers with help of Geolocation latitude and langitude which must be fetched from custom object (Contact_Check_In__c)

My Custom Object name is Contact_Check_In__c
 and i have fields called geolocation(GeoLocation__c)
With Lot of effort and searching i came accross vf page and apex controller, all is ok but it is not capturing the Live Geolocation

all i want is vf page has to take the dynamic geolocation from the record and show it on the google maps on vf page

i refered this blogs still not able to resolve my issue
https://developer.salesforce.com/forums?id=906F0000000AKp5IAG
https://success.salesforce.com/answers?id=90630000000guBkAAI

Any help would be highly appreciated

Below are my VF page
<apex:page StandardController="Contact_Check_In__c" extensions="MyCheckInController" lightningStylesheets="true" docType="HTML-5.0">

<html>
  <head>
   <title>Check In Detail</title>
   <style>
      /* Always set the map height explicitly to define the size of the div
       * element that contains the map. */
      #map {
        height: 90%;
      }
      /* Optional: Makes the sample page fill the window. */
      html, body {
        height: 90%;
        margin: 0;
        padding: 0;
      }
    </style>
  </head>

  <body onload = "loadMap()">
    <h2>Check In on the Map</h2>
    <div id = "map" ></div>
      <script>

        
        function loadMap() {
          // Initialize Google Maps
          const mapOptions = {
            center:new google.maps.LatLng(13.0161331,76.0898104),
            zoom: 13
          }
          const map = new google.maps.Map(document.getElementById("map"), mapOptions);
          
          var text = '{!JsonCheckInData}';
          var iconBase = 'https://maps.google.com/mapfiles/kml/shapes/';
            var icons = {
              parking: {
                icon: iconBase + 'parking_lot_maps.png'
              },
              library: {
                icon: iconBase + 'library_maps.png'
              },
              info: {
                icon: iconBase + 'info-i_maps.png'
              }
            };
            
          var obj = JSON.parse(text);
          //alert(obj);
          //return obj;
          var x;
          var jsonData='';
          var loc1='';
          var loc2;
          var address='';
          for (x in obj) {
           
            temp=obj[x].location.split(",");
            loc1=temp[0].replace("[", "");
            loc2=temp[1].replace("]", "");
            
                                   
            let marker = new google.maps.Marker({
              map: map,
              icon:icons['library'].icon,
              position: new google.maps.LatLng(loc1, loc2),
              title: 'Person Name:' +  obj[x].name + ' CheckIn:' +obj[x].checkIn 
            })
            
            
          } 
        
        }
      </script>
      <!--<script src = "https://maps.googleapis.com/maps/api/js"></script>-->
     <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBqqej11sosokXGaQTk_-Zw9AIXMVkXoAE&callback=loadMap">
    </script>
    {!JsonCheckInData}
  </body>
</html>
</apex:page>

My Controller
 
public class MyCheckInController {

    public MyCheckInController(ApexPages.StandardController controller) {

    }


    public list<Contact_Check_In__c> LstContactCheckIn{get;set;}
    
    public string JsonCheckInData{get;set;}

    public MyCheckInController(){
        
        LstContactCheckIn=[Select Id, CheckIn_Date_Time__c, GeoLocation__latitude__s, GeoLocation__longitude__s, Contact__r.Name from Contact_Check_In__c];
        
        list<WrpData> lstWrpData=new list<WrpData>();
        
        for(Contact_Check_In__c Check:LstContactCheckIn){
               string strLocation='[' + string.valueOf(check.GeoLocation__latitude__s) + ','  + string.valueOf(check.GeoLocation__longitude__s)+ ']';
               WrpData wrp=new WrpData(check.Contact__r.Name, strLocation, string.ValueOf(check.CheckIn_Date_Time__c),string.valueOf(check.GeoLocation__latitude__s),string.valueOf(check.GeoLocation__longitude__s));
               lstWrpData.add(wrp);
        }
        
        JsonCheckInData=Json.Serialize(lstWrpData);
        
    }
    
    public class WrpData{
        
        public string name{get;set;}
        public string location{get;set;}
        public string checkIn{get;set;}
        public string lat{get;set;}
        public string lng{get;set;}
        public WrpData(string nm,string loc,string chkIn, string lt,string ln){
            name=nm;
            location=loc;
            checkIn=chkIn;
            lat=lt;
            lng=ln;
        }
    }
   
}

​​​​​​​

 
Hello Developers

i am trying to design a Test class for the Apex class but i am not able to do the code coverage of the following apex class, can anyone please help
 
public class FutureHandler {
    
    @future
    public static void updaterecs(Map<String,Id> oldManagerQuotaMap1){
        Map<Id,Quota__c> oldMapQuota = new Map<Id,Quota__c>();
        if(null != oldManagerQuotaMap1 && oldManagerQuotaMap1.size() > 0){
            for (aggregateResult result: [Select Manager_Quota__c, Sum(Inside_Sales_Roll_Up__c) 
                                          FROM Quota__c WHERE 
                                          Manager_Quota__c IN: oldManagerQuotaMap1.values() 
                                          GROUP BY Manager_Quota__c]) {
                                              system.debug('result'+result)    ;          
                                              oldMapQuota.put((Id)result.get('Manager_Quota__c'),new Quota__c(Id=(Id)result.get('Manager_Quota__c'),Actual_Amount__c =(Decimal)result.get('expr0')));         
                                          }
            
            for(Id qId : oldManagerQuotaMap1.values()){
                if(!oldMapQuota.containskey(qId)){
                    oldMapQuota.put(qId, new Quota__c(Id = qId,Actual_Amount__c = 0.0));
                }
            }
            
            if(null != oldMapQuota && oldMapQuota.size() > 0){
                update oldMapQuota.values();
            }
            
        }
    }

    public static void sendOppsForApproval(List<Opportunity> opps){
        
        List<Opportunity> oppsToBeSentForApproval = new List<Opportunity>();
        String monthYear = System.now().format('MMMM-yyyy');
        String month = monthYear.split('-')[0];
        String year = monthYear.split('-')[1];
        Date nextMonthStart = System.today().toStartOfMonth().addMonths(1).toStartOfMonth();
        List<Aggregate_Approval__c> appr = [Select Id from Aggregate_Approval__c where Month__c=:month And Year__c=:year]; 
        Id approvalId;
        if(appr.size()>0){
            approvalId = appr[0].Id;
            
            for(Opportunity opp : opps){
                opp.Aggregate_Approval__c = approvalId;
                opp.Status__c = 'In Approval';
                oppsToBeSentForApproval.add(opp);
            }
            update oppsToBeSentForApproval;
           // List<Approval.LockResult> li = Approval.lock(opps);
            
            Approval.ProcessSubmitRequest oppAggregateApproval = new Approval.ProcessSubmitRequest();
            oppAggregateApproval.setComments('Submitting opportunities for Approval for '+System.now().format('MMMM-yyyy'));
            oppAggregateApproval.setObjectId(approvalId);
            Approval.ProcessResult approvalResult = Approval.process(oppAggregateApproval); 
            
        } 
    }
}
My Test Class
 
@isTest
public class FutureHandlerTestclass {
    
    static testmethod void Futuretest(){
        
        List<Quota__c> Ftur = new list <Quota__c>();
        Quota__c FF = new Quota__c();
        FF.Name='Julian';
        FF.Assigned_To__c = userinfo.getUserId();
        FF.Month__c='March';  
        FF.Quater__c='Q1';       
        FF.Quater_Year__c = '2020';
        FF.Actual_Amount__c = 100;
        FF.Unique_Identifier_Per_Quater_Per_User__c = 'Hello';
        Ftur.add(FF);
        insert FF;
        
        
        Quota__c FF1 = new Quota__c();
        FF1.Name='rahul';
        FF1.Assigned_To__c = userinfo.getUserId();
        FF1.Month__c='October';  
        FF1.Quater__c='Q4';       
        FF1.Quater_Year__c = '2030';
        FF.Actual_Amount__c = 200;
        FF1.Unique_Identifier_Per_Quater_Per_User__c = 'Helloworld';
        Ftur.add(FF1);
        insert FF1;
        
        Account testAcct = new Account (Name = 'My Test Account');
        insert testAcct;
        
        User u = [Select id,name from user where isactive=true Limit 1];
        
        List<Opportunity> Oppps = new list <Opportunity>(); 
        Opportunity oop = new Opportunity();
        
        oop.Name = 'Test1';
        oop.AccountId = testAcct.ID;
        oop.StageName = 'Demo';
        oop.CloseDate = system.today();
        oop.Billing_To_Be_Initiated__c = 'Yes';
        oop.LeadSource = 'Customer';
        oop.Country__c = 'India';        
        Oppps.add(oop);
        insert oop;
    }
    }