• Gatorrr7
  • NEWBIE
  • 10 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 3
    Replies
please correct this code and help me earn this badge ...have completed all tasks ..except this one ....

IF( MONTH( NOW() ) = 12,
  DATE( YEAR( NOW() ), 12, 31 ),
  DATE( YEAR( NOW() ), MONTH( NOW() ) + 1, 1) - 1
I would like to create a visualforce page that will use the address of a Contact in Salesforce, and determine which one of our ground campus locations is the closest, and display the campus name and distance. I assume that I would need the Latitude, Longitude coordinates for each campus, then somehow tie that into the directions portion of Google Maps... But I'm honestly not sure where to begin with this.
I have found this page: 

http://help.salesforce.com/apex/HTViewHelpDoc?id=custom_field_geolocate_overview.htm#custom_field_geolocate_overview&language=en

which goes into some detail about using the "distance formula" but I am new to Apex coding and using geolocation information, and I don't know how I would access the directions function of Google Maps to utilize and compare the distances to each campus, then display the smallest value/distance.

Any input would be greatly apreciated!
  • December 21, 2015
  • Like
  • 0
i am trying to build a lightning component that shows nearby contacts based on the users current location. i am getting an error when trying to access the users current location through navigator.geoLocation. I get the following error.
"Uncaught error in actionCallback : navigator.geoLocation is undefined"

Here is my component and its controller logic.

Component:
<aura:component >
    
   <aura:attribute name="latitude" type="Decimal"/>
    <aura:attribute name="longitude" type="Decimal"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
  
</aura:component>
Controller:
({
	doInit : function(component, event, helper) {
        if(navigator.geoLocation){
            console.log("capability is there");
            
        }else{
            console.log("No Capability");
        }
        navigator.geoLocation.getCurrentPosition(function(position){
            this.latitude=component.set("v.latitude",position.coords.latitude);
            this.longitude=component.set("v.longitude", position.coords.longitude);
            console.log("Latitude is:"+this.latitude);
            console.log("Longitude is:" +this.longitude);
        });
		
	}
})
debugging  console log shows that my else part is only written to console. does that mean that geolocation is not supported in lightning? Am i doing anything wrong ? Any help would be appreciated.