• nansi kela 21
  • NEWBIE
  • 90 Points
  • Member since 2016

  • Chatter
    Feed
  • 1
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 18
    Replies
Hi Everyone,

I want to get google map for current location viewing  & longitude and latitude without api key.

google javascript api v3  js file Link
https://maps.googleapis.com/maps/api/js

Codes:

1.VF Code:
<apex:page sidebar="false" showheader="false" standardController="Account"  extensions="FindNearby">
    
    <!-- Include in Google's Maps API via JavaScript static resource -->
    <apex:includeScript value="{!$Resource.googleMapsAPI}" /> 
    
    <!-- Set this API key to fix JavaScript errors in production -->
    <!--http://salesforcesolutions.blogspot.com/2013/01/integration-of-salesforcecom-and-google.html-->
    <script type="text/javascript" 
       src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"> <!-- We try to get google mapy without API Key (Javascript V3) but i did not show the current location as well as longitude and latitude -->
<!-- src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAowmYdY3dZwoe4qI1I_X8Ry-UPepb5dpA&sensor=false">   previously we used API key to generate Google Map but  the usage of API key is very limited(Only 4 times)  -->

        </script>
        
    <!-- Setup the map to take up the whole window --> 
    <style>
        html, body { height: 100%; }
        .page-map, .ui-content, #map-canvas { width: 100%; height:100%; padding: 0; }
        #map-canvas { height: min-height: 100%; }
    </style>
    
    <script>
        function initialize() {
            var lat, lon;
              
             // If we can, get the position of the user via device geolocation
             if (navigator.geolocation) {
                 navigator.geolocation.getCurrentPosition(function(position){
                     lat = position.coords.latitude;
                     lon = position.coords.longitude;                    
                     
                     // Use Visualforce JavaScript Remoting to query for nearby accts      
                     Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.FindNearby.getNearby}', lat, lon,
                         function(result, event){
                             if (event.status) {
                                 console.log(result);
                                 createMap(lat, lon, result);           
                             } else if (event.type === 'exception') {
                                 //exception case code          
                             } else {
                                            
                             }
                          }, 
                          {escape: true}
                      );
                  });
              } else {
                  // Set default values for map if the device doesn't have geolocation capabilities
                    /** Eindhoven **/
                    lat = 12.9172;
                    lon = 80.1929;
                    
                    var result = [];
                    createMap(lat, lon, result);
              }
          
         }
    
         function createMap(lat, lon, accts)
    {
            // Get the map div, and center the map at the proper geolocation
            var currentPosition = new google.maps.LatLng(lat,lon);
            var mapDiv = document.getElementById('map-canvas');
            var map = new google.maps.Map(mapDiv, {
                center: currentPosition, 
                zoom: 13,
                mapTypeId: google.maps.MapTypeId.ROADTYPE
            });
           
            // Set a marker for the current location
            var positionMarker = new google.maps.Marker({
                map: map,
                position: currentPosition,
                icon: 'http://maps.google.com/mapfiles/ms/micons/pink.png'
            });
            
                        
            // Keep track of the map boundary that holds all markers
            var mapBoundary = new google.maps.LatLngBounds();
            mapBoundary.extend(currentPosition);
            
            // Set markers on the map from the @RemoteAction results
            var acct;
            for(var i=0; i<accts.length;i++){
                acct = accts[i];
                console.log(accts[i]);
                setupMarker();
            }
            
            // Resize map to neatly fit all of the markers
            map.fitBounds(mapBoundary);

           function setupMarker(){ 
                var acctNavUrl;
                
                // Determine if we are in Salesforce1 and set navigation link appropriately
                try{
                    if(sforce.one){
                        acctNavUrl = 
                            'javascript:sforce.one.navigateToSObject(\'' + acct.Id + '\')';
                    }
                } catch(err) {
                    console.log(err);
                    acctNavUrl = '\\' + acct.Id;
                }
                
                var acctDetails = 
                    '<a href="' + acctNavUrl + '">' + 
                    acct.Name + '</a><br/>' + 
                    acct.BillingStreet + '<br/>' + 
                    acct.BillingCity + '<br/>' + 
                    acct.Phone;
               
               // Create the callout that will pop up on the marker     
               var infowindow = new google.maps.InfoWindow({ 
                   content: acctDetails
               });
               
               // Place the marker on the map   
               var marker = new google.maps.Marker({
                   map: map,
                   position: new google.maps.LatLng( 
                                   acct.Location__Latitude__s, 
                                   acct.Location__Longitude__s)
               });
               mapBoundary.extend(marker.getPosition());
               
               // Add the action to open up the panel when it's marker is clicked      
               google.maps.event.addListener(marker, 'click', function(){
                   infowindow.open(map, marker);
               });
           }
        }
        
        // Fire the initialize function when the window loads
        google.maps.event.addDomListener(window, 'load', initialize);
        
    </script>
    
    
    <body style="font-family: Arial; border: 0 none;">
       
   <!--  All content is rendered by the Google Maps code -->
    <!--  This minimal HTML justs provide a target for GMaps to write to -->
        <div id="map-canvas"></div>
    </body>
</apex:page>

2.Apex Class --- FindNearby
global with sharing class FindNearby {

   public FindNearby(ApexPages.StandardController sc){} 
    
    @RemoteAction
    // Find Accounts nearest a geolocation
    global static List<Account> getNearby(String lat, String lon) {

        // If geolocation isn't set, use Eindhoven (or any other city)
        // Put a default location latitue and longitude here, this could be where you are located the most
        // and will only be used as a backup if the browser can not get your location details
        if(lat == null || lon == null || lat.equals('') || lon.equals('')) {
            lat = '51.096214';
            lon = '3.683153';
        }

        // SOQL query to get the nearest accounts
        //you can change km (kilometers) into mi (miles)
        // < 20 means within a radius of 20 km or mi (you can change that)
        //limit 25 shows 25 records (you can adapt that too if you want)
        String queryString =
            'SELECT Id, Name, Location__Longitude__s, Location__Latitude__s, ' +
                'BillingStreet, Phone, BillingCity ' +
            'FROM Account ' +
            'WHERE DISTANCE(Location__c, GEOLOCATION('+lat+','+lon+'), \'km\') < 20 ' +
            'ORDER BY DISTANCE(Location__c, GEOLOCATION('+lat+','+lon+'), \'km\') ' +
            'LIMIT 25';

        // Run and return the query results
        return(database.Query(queryString));
    }
}

3.Apex Trigger
// Trigger runs getLocation() on Accounts with no Geolocation
trigger SetGeolocation on Account (after insert, after update) {
    for (Account a : trigger.new){
        if(Trigger.isUpdate){
            if(a.BillingStreet != Trigger.oldMap.get(a.id).BillingStreet || a.BillingCity != Trigger.oldMap.get(a.id).BillingCity || a.BillingPostalCode != Trigger.oldMap.get(a.id).BillingPostalCode){
                LocationCallouts.getLocation(a.id);
            }
        }
        if (a.Location__Latitude__s == null)
            LocationCallouts.getLocation(a.id);
}
}

4.Apex Class

public class LocationCallouts {
 
     @future (callout=true)  // future method needed to run callouts from Triggers
      static public void getLocation(id accountId){
        // gather account info
        Account a = [SELECT BillingCity,BillingCountry,BillingPostalCode,BillingState,BillingStreet FROM Account WHERE id =: accountId];
 
        // create an address string
        String address = '';
        if (a.BillingStreet != null)
            address += a.BillingStreet +', ';
        if (a.BillingCity != null)
            address += a.BillingCity +', ';
        if (a.BillingState != null)
            address += a.BillingState +' ';
        if (a.BillingPostalCode != null)
            address += a.BillingPostalCode +', ';
        if (a.BillingCountry != null)
            address += a.BillingCountry;
 
        address = EncodingUtil.urlEncode(address, 'UTF-8');
 
        // build callout
        Http h = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint('http://maps.googleapis.com/maps/api/geocode/json?address='+address+'&sensor=false');
        req.setMethod('GET');
        req.setTimeout(6000);
 
        try{
            // callout
            HttpResponse res = h.send(req);
             System.debug(res.getBody());
            // parse coordinates from response
            JSONParser parser = JSON.createParser(res.getBody());
            double lat = null;
            double lon = null;
            while (parser.nextToken() != null) {
                if ((parser.getCurrentToken() == JSONToken.FIELD_NAME) &&
                    (parser.getText() == 'location')){
                       parser.nextToken(); // object start
                       while (parser.nextToken() != JSONToken.END_OBJECT){
                           String txt = parser.getText();
                           parser.nextToken();
                           if (txt == 'lat')
                               lat = parser.getDoubleValue();
                           else if (txt == 'lng')
                               lon = parser.getDoubleValue();
                       }
 
                }
            }
 
            // update coordinates if we get back
            if (lat != null){
                a.Location__Latitude__s = lat;
                a.Location__Longitude__s = lon;
                update a;
            }
 
        } catch (Exception e) {
        }
    }
}

Thanks in advance,
If anybody know please tell me.

Thanks and Regards,
Sivasankari.M
Hello,

Can we add Url type field under Company Information?
Setup --> Company Profile -->Company Information.

Thanks and Regards,
Nansi
 
Hello,
please tell me about Home page component in lightning experience
Home page component in salesforce classic is compatible with lightning experience?
I have two application which are shown to the home page component in salesforce classic. so Now I want to show them also
in lightning experience.. 
Please provide me any solution regarding it,

Thanks and Regards,
Nansi kela
Hi,
how to remove selected items from selectlist ?

Thanks,
Nansi
Hi.
 
i am working with custom metadata type .. I want to create one formula type field in custom metadata type object..
Please give me some solution..

Thank you..
Nansi kela
Hi..
I am working with custom meta data type.. now i need to update record of custom  metadata type by edit button in vf page..
so please tell me can we update record of custom metadata  in vf page..

Thanks and regards,
Nansi kela..
 
Hi,
how to remove selected items from selectlist ?

Thanks,
Nansi

Hi,
I'm looking for an app or a way to implement a CMS in Force.com.
In my researches I have found the Site.com, OrchestraCMS and the CMSForce 2, but both have the latest posts in 2013/2014.

Does anyone knows an app for CMS? How could I implement it?

Thanks!

Hello,

Can we add Url type field under Company Information?
Setup --> Company Profile -->Company Information.

Thanks and Regards,
Nansi
 
Good day!

I have a question for setting CNAME.

Our company need to get CNAME to connect another URL.
(for example, www.abc.co.kr(Use another server provider) connect with our communities.
And I searched and it is need to CNAME for this work.)

As I search, when make community, CNAME will be

[domain name].[Organization ID].live.salesforce.com

So, our community's CNAME is afr-artifacts-developer-edition.ap2.force.com.00D28000000rCfy.live.salesforce.com right?

And I tried to check our CNAME on [Site Configuration] -[Domains] in site.com.

But, There is just Domain name afr-artifacts-developer-edition.ap2.force.com and path.

Noe certificate name on site.com.

So, I searched more, I understand it is need to register custom domain and setting Certificates.

My question's point is Here.

1. Can I use [afr-artifacts-developer-edition.ap2.force.com.00D28000000rCfy.live.salesforce.com] right now?

2. If not, how can I use that CNAME to use? make custom domain and set up Certificate?

Thanks for your help

Best regards.
  • March 31, 2016
  • Like
  • 0
Hello,
please tell me about Home page component in lightning experience
Home page component in salesforce classic is compatible with lightning experience?
I have two application which are shown to the home page component in salesforce classic. so Now I want to show them also
in lightning experience.. 
Please provide me any solution regarding it,

Thanks and Regards,
Nansi kela
Hi.
 
i am working with custom metadata type .. I want to create one formula type field in custom metadata type object..
Please give me some solution..

Thank you..
Nansi kela
Hi..
I am working with custom meta data type.. now i need to update record of custom  metadata type by edit button in vf page..
so please tell me can we update record of custom metadata  in vf page..

Thanks and regards,
Nansi kela..
 
Hi Everyone,

I want to get google map for current location viewing  & longitude and latitude without api key.

google javascript api v3  js file Link
https://maps.googleapis.com/maps/api/js

Codes:

1.VF Code:
<apex:page sidebar="false" showheader="false" standardController="Account"  extensions="FindNearby">
    
    <!-- Include in Google's Maps API via JavaScript static resource -->
    <apex:includeScript value="{!$Resource.googleMapsAPI}" /> 
    
    <!-- Set this API key to fix JavaScript errors in production -->
    <!--http://salesforcesolutions.blogspot.com/2013/01/integration-of-salesforcecom-and-google.html-->
    <script type="text/javascript" 
       src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"> <!-- We try to get google mapy without API Key (Javascript V3) but i did not show the current location as well as longitude and latitude -->
<!-- src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAowmYdY3dZwoe4qI1I_X8Ry-UPepb5dpA&sensor=false">   previously we used API key to generate Google Map but  the usage of API key is very limited(Only 4 times)  -->

        </script>
        
    <!-- Setup the map to take up the whole window --> 
    <style>
        html, body { height: 100%; }
        .page-map, .ui-content, #map-canvas { width: 100%; height:100%; padding: 0; }
        #map-canvas { height: min-height: 100%; }
    </style>
    
    <script>
        function initialize() {
            var lat, lon;
              
             // If we can, get the position of the user via device geolocation
             if (navigator.geolocation) {
                 navigator.geolocation.getCurrentPosition(function(position){
                     lat = position.coords.latitude;
                     lon = position.coords.longitude;                    
                     
                     // Use Visualforce JavaScript Remoting to query for nearby accts      
                     Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.FindNearby.getNearby}', lat, lon,
                         function(result, event){
                             if (event.status) {
                                 console.log(result);
                                 createMap(lat, lon, result);           
                             } else if (event.type === 'exception') {
                                 //exception case code          
                             } else {
                                            
                             }
                          }, 
                          {escape: true}
                      );
                  });
              } else {
                  // Set default values for map if the device doesn't have geolocation capabilities
                    /** Eindhoven **/
                    lat = 12.9172;
                    lon = 80.1929;
                    
                    var result = [];
                    createMap(lat, lon, result);
              }
          
         }
    
         function createMap(lat, lon, accts)
    {
            // Get the map div, and center the map at the proper geolocation
            var currentPosition = new google.maps.LatLng(lat,lon);
            var mapDiv = document.getElementById('map-canvas');
            var map = new google.maps.Map(mapDiv, {
                center: currentPosition, 
                zoom: 13,
                mapTypeId: google.maps.MapTypeId.ROADTYPE
            });
           
            // Set a marker for the current location
            var positionMarker = new google.maps.Marker({
                map: map,
                position: currentPosition,
                icon: 'http://maps.google.com/mapfiles/ms/micons/pink.png'
            });
            
                        
            // Keep track of the map boundary that holds all markers
            var mapBoundary = new google.maps.LatLngBounds();
            mapBoundary.extend(currentPosition);
            
            // Set markers on the map from the @RemoteAction results
            var acct;
            for(var i=0; i<accts.length;i++){
                acct = accts[i];
                console.log(accts[i]);
                setupMarker();
            }
            
            // Resize map to neatly fit all of the markers
            map.fitBounds(mapBoundary);

           function setupMarker(){ 
                var acctNavUrl;
                
                // Determine if we are in Salesforce1 and set navigation link appropriately
                try{
                    if(sforce.one){
                        acctNavUrl = 
                            'javascript:sforce.one.navigateToSObject(\'' + acct.Id + '\')';
                    }
                } catch(err) {
                    console.log(err);
                    acctNavUrl = '\\' + acct.Id;
                }
                
                var acctDetails = 
                    '<a href="' + acctNavUrl + '">' + 
                    acct.Name + '</a><br/>' + 
                    acct.BillingStreet + '<br/>' + 
                    acct.BillingCity + '<br/>' + 
                    acct.Phone;
               
               // Create the callout that will pop up on the marker     
               var infowindow = new google.maps.InfoWindow({ 
                   content: acctDetails
               });
               
               // Place the marker on the map   
               var marker = new google.maps.Marker({
                   map: map,
                   position: new google.maps.LatLng( 
                                   acct.Location__Latitude__s, 
                                   acct.Location__Longitude__s)
               });
               mapBoundary.extend(marker.getPosition());
               
               // Add the action to open up the panel when it's marker is clicked      
               google.maps.event.addListener(marker, 'click', function(){
                   infowindow.open(map, marker);
               });
           }
        }
        
        // Fire the initialize function when the window loads
        google.maps.event.addDomListener(window, 'load', initialize);
        
    </script>
    
    
    <body style="font-family: Arial; border: 0 none;">
       
   <!--  All content is rendered by the Google Maps code -->
    <!--  This minimal HTML justs provide a target for GMaps to write to -->
        <div id="map-canvas"></div>
    </body>
</apex:page>

2.Apex Class --- FindNearby
global with sharing class FindNearby {

   public FindNearby(ApexPages.StandardController sc){} 
    
    @RemoteAction
    // Find Accounts nearest a geolocation
    global static List<Account> getNearby(String lat, String lon) {

        // If geolocation isn't set, use Eindhoven (or any other city)
        // Put a default location latitue and longitude here, this could be where you are located the most
        // and will only be used as a backup if the browser can not get your location details
        if(lat == null || lon == null || lat.equals('') || lon.equals('')) {
            lat = '51.096214';
            lon = '3.683153';
        }

        // SOQL query to get the nearest accounts
        //you can change km (kilometers) into mi (miles)
        // < 20 means within a radius of 20 km or mi (you can change that)
        //limit 25 shows 25 records (you can adapt that too if you want)
        String queryString =
            'SELECT Id, Name, Location__Longitude__s, Location__Latitude__s, ' +
                'BillingStreet, Phone, BillingCity ' +
            'FROM Account ' +
            'WHERE DISTANCE(Location__c, GEOLOCATION('+lat+','+lon+'), \'km\') < 20 ' +
            'ORDER BY DISTANCE(Location__c, GEOLOCATION('+lat+','+lon+'), \'km\') ' +
            'LIMIT 25';

        // Run and return the query results
        return(database.Query(queryString));
    }
}

3.Apex Trigger
// Trigger runs getLocation() on Accounts with no Geolocation
trigger SetGeolocation on Account (after insert, after update) {
    for (Account a : trigger.new){
        if(Trigger.isUpdate){
            if(a.BillingStreet != Trigger.oldMap.get(a.id).BillingStreet || a.BillingCity != Trigger.oldMap.get(a.id).BillingCity || a.BillingPostalCode != Trigger.oldMap.get(a.id).BillingPostalCode){
                LocationCallouts.getLocation(a.id);
            }
        }
        if (a.Location__Latitude__s == null)
            LocationCallouts.getLocation(a.id);
}
}

4.Apex Class

public class LocationCallouts {
 
     @future (callout=true)  // future method needed to run callouts from Triggers
      static public void getLocation(id accountId){
        // gather account info
        Account a = [SELECT BillingCity,BillingCountry,BillingPostalCode,BillingState,BillingStreet FROM Account WHERE id =: accountId];
 
        // create an address string
        String address = '';
        if (a.BillingStreet != null)
            address += a.BillingStreet +', ';
        if (a.BillingCity != null)
            address += a.BillingCity +', ';
        if (a.BillingState != null)
            address += a.BillingState +' ';
        if (a.BillingPostalCode != null)
            address += a.BillingPostalCode +', ';
        if (a.BillingCountry != null)
            address += a.BillingCountry;
 
        address = EncodingUtil.urlEncode(address, 'UTF-8');
 
        // build callout
        Http h = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint('http://maps.googleapis.com/maps/api/geocode/json?address='+address+'&sensor=false');
        req.setMethod('GET');
        req.setTimeout(6000);
 
        try{
            // callout
            HttpResponse res = h.send(req);
             System.debug(res.getBody());
            // parse coordinates from response
            JSONParser parser = JSON.createParser(res.getBody());
            double lat = null;
            double lon = null;
            while (parser.nextToken() != null) {
                if ((parser.getCurrentToken() == JSONToken.FIELD_NAME) &&
                    (parser.getText() == 'location')){
                       parser.nextToken(); // object start
                       while (parser.nextToken() != JSONToken.END_OBJECT){
                           String txt = parser.getText();
                           parser.nextToken();
                           if (txt == 'lat')
                               lat = parser.getDoubleValue();
                           else if (txt == 'lng')
                               lon = parser.getDoubleValue();
                       }
 
                }
            }
 
            // update coordinates if we get back
            if (lat != null){
                a.Location__Latitude__s = lat;
                a.Location__Longitude__s = lon;
                update a;
            }
 
        } catch (Exception e) {
        }
    }
}

Thanks in advance,
If anybody know please tell me.

Thanks and Regards,
Sivasankari.M
Hi Everyone,

I want to get google map for current location viewing  & longitude and latitude without api key.

google javascript api v3  js file Link
https://maps.googleapis.com/maps/api/js

Codes:

1.VF Code:
<apex:page sidebar="false" showheader="false" standardController="Account"  extensions="FindNearby">
    
    <!-- Include in Google's Maps API via JavaScript static resource -->
    <apex:includeScript value="{!$Resource.googleMapsAPI}" /> 
    
    <!-- Set this API key to fix JavaScript errors in production -->
    <!--http://salesforcesolutions.blogspot.com/2013/01/integration-of-salesforcecom-and-google.html-->
    <script type="text/javascript" 
       src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"> <!-- We try to get google mapy without API Key (Javascript V3) but i did not show the current location as well as longitude and latitude -->
<!-- src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAowmYdY3dZwoe4qI1I_X8Ry-UPepb5dpA&sensor=false">    previously we used API key to generate Google Map but  the usage of API key is very limited(Only 4 times)  -->

        </script>
        
    <!-- Setup the map to take up the whole window --> 
    <style>
        html, body { height: 100%; }
        .page-map, .ui-content, #map-canvas { width: 100%; height:100%; padding: 0; }
        #map-canvas { height: min-height: 100%; }
    </style>
    
    <script>
        function initialize() {
            var lat, lon;
              
             // If we can, get the position of the user via device geolocation
             if (navigator.geolocation) {
                 navigator.geolocation.getCurrentPosition(function(position){
                     lat = position.coords.latitude;
                     lon = position.coords.longitude;                    
                     
                     // Use Visualforce JavaScript Remoting to query for nearby accts      
                     Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.FindNearby.getNearby}', lat, lon,
                         function(result, event){
                             if (event.status) {
                                 console.log(result);
                                 createMap(lat, lon, result);           
                             } else if (event.type === 'exception') {
                                 //exception case code          
                             } else {
                                            
                             }
                          }, 
                          {escape: true}
                      );
                  });
              } else {
                  // Set default values for map if the device doesn't have geolocation capabilities
                    /** Eindhoven **/
                    lat = 12.9172;
                    lon = 80.1929;
                    
                    var result = [];
                    createMap(lat, lon, result);
              }
          
         }
    
         function createMap(lat, lon, accts)
    {
            // Get the map div, and center the map at the proper geolocation
            var currentPosition = new google.maps.LatLng(lat,lon);
            var mapDiv = document.getElementById('map-canvas');
            var map = new google.maps.Map(mapDiv, {
                center: currentPosition, 
                zoom: 13,
                mapTypeId: google.maps.MapTypeId.ROADTYPE
            });
           
            // Set a marker for the current location
            var positionMarker = new google.maps.Marker({
                map: map,
                position: currentPosition,
                icon: 'http://maps.google.com/mapfiles/ms/micons/pink.png'
            });
            
                        
            // Keep track of the map boundary that holds all markers
            var mapBoundary = new google.maps.LatLngBounds();
            mapBoundary.extend(currentPosition);
            
            // Set markers on the map from the @RemoteAction results
            var acct;
            for(var i=0; i<accts.length;i++){
                acct = accts[i];
                console.log(accts[i]);
                setupMarker();
            }
            
            // Resize map to neatly fit all of the markers
            map.fitBounds(mapBoundary);

           function setupMarker(){ 
                var acctNavUrl;
                
                // Determine if we are in Salesforce1 and set navigation link appropriately
                try{
                    if(sforce.one){
                        acctNavUrl = 
                            'javascript:sforce.one.navigateToSObject(\'' + acct.Id + '\')';
                    }
                } catch(err) {
                    console.log(err);
                    acctNavUrl = '\\' + acct.Id;
                }
                
                var acctDetails = 
                    '<a href="' + acctNavUrl + '">' + 
                    acct.Name + '</a><br/>' + 
                    acct.BillingStreet + '<br/>' + 
                    acct.BillingCity + '<br/>' + 
                    acct.Phone;
               
               // Create the callout that will pop up on the marker     
               var infowindow = new google.maps.InfoWindow({ 
                   content: acctDetails
               });
               
               // Place the marker on the map   
               var marker = new google.maps.Marker({
                   map: map,
                   position: new google.maps.LatLng( 
                                   acct.Location__Latitude__s, 
                                   acct.Location__Longitude__s)
               });
               mapBoundary.extend(marker.getPosition());
               
               // Add the action to open up the panel when it's marker is clicked      
               google.maps.event.addListener(marker, 'click', function(){
                   infowindow.open(map, marker);
               });
           }
        }
        
        // Fire the initialize function when the window loads
        google.maps.event.addDomListener(window, 'load', initialize);
        
    </script>
    
    
    <body style="font-family: Arial; border: 0 none;">
       
   <!--  All content is rendered by the Google Maps code -->
    <!--  This minimal HTML justs provide a target for GMaps to write to -->
        <div id="map-canvas"></div>
    </body>
</apex:page>

2.Apex Class --- FindNearby
global with sharing class FindNearby {

   public FindNearby(ApexPages.StandardController sc){} 
    
    @RemoteAction
    // Find Accounts nearest a geolocation
    global static List<Account> getNearby(String lat, String lon) {

        // If geolocation isn't set, use Eindhoven (or any other city)
        // Put a default location latitue and longitude here, this could be where you are located the most
        // and will only be used as a backup if the browser can not get your location details
        if(lat == null || lon == null || lat.equals('') || lon.equals('')) {
            lat = '51.096214';
            lon = '3.683153';
        }

        // SOQL query to get the nearest accounts
        //you can change km (kilometers) into mi (miles)
        // < 20 means within a radius of 20 km or mi (you can change that)
        //limit 25 shows 25 records (you can adapt that too if you want)
        String queryString =
            'SELECT Id, Name, Location__Longitude__s, Location__Latitude__s, ' +
                'BillingStreet, Phone, BillingCity ' +
            'FROM Account ' +
            'WHERE DISTANCE(Location__c, GEOLOCATION('+lat+','+lon+'), \'km\') < 20 ' +
            'ORDER BY DISTANCE(Location__c, GEOLOCATION('+lat+','+lon+'), \'km\') ' +
            'LIMIT 25';

        // Run and return the query results
        return(database.Query(queryString));
    }
}

3.Apex Trigger
// Trigger runs getLocation() on Accounts with no Geolocation
trigger SetGeolocation on Account (after insert, after update) {
    for (Account a : trigger.new){
        if(Trigger.isUpdate){
            if(a.BillingStreet != Trigger.oldMap.get(a.id).BillingStreet || a.BillingCity != Trigger.oldMap.get(a.id).BillingCity || a.BillingPostalCode != Trigger.oldMap.get(a.id).BillingPostalCode){
                LocationCallouts.getLocation(a.id);
            }
        }
        if (a.Location__Latitude__s == null)
            LocationCallouts.getLocation(a.id);
}
}

4.Apex Class

public class LocationCallouts {
 
     @future (callout=true)  // future method needed to run callouts from Triggers
      static public void getLocation(id accountId){
        // gather account info
        Account a = [SELECT BillingCity,BillingCountry,BillingPostalCode,BillingState,BillingStreet FROM Account WHERE id =: accountId];
 
        // create an address string
        String address = '';
        if (a.BillingStreet != null)
            address += a.BillingStreet +', ';
        if (a.BillingCity != null)
            address += a.BillingCity +', ';
        if (a.BillingState != null)
            address += a.BillingState +' ';
        if (a.BillingPostalCode != null)
            address += a.BillingPostalCode +', ';
        if (a.BillingCountry != null)
            address += a.BillingCountry;
 
        address = EncodingUtil.urlEncode(address, 'UTF-8');
 
        // build callout
        Http h = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint('http://maps.googleapis.com/maps/api/geocode/json?address='+address+'&sensor=false');
        req.setMethod('GET');
        req.setTimeout(6000);
 
        try{
            // callout
            HttpResponse res = h.send(req);
             System.debug(res.getBody());
            // parse coordinates from response
            JSONParser parser = JSON.createParser(res.getBody());
            double lat = null;
            double lon = null;
            while (parser.nextToken() != null) {
                if ((parser.getCurrentToken() == JSONToken.FIELD_NAME) &&
                    (parser.getText() == 'location')){
                       parser.nextToken(); // object start
                       while (parser.nextToken() != JSONToken.END_OBJECT){
                           String txt = parser.getText();
                           parser.nextToken();
                           if (txt == 'lat')
                               lat = parser.getDoubleValue();
                           else if (txt == 'lng')
                               lon = parser.getDoubleValue();
                       }
 
                }
            }
 
            // update coordinates if we get back
            if (lat != null){
                a.Location__Latitude__s = lat;
                a.Location__Longitude__s = lon;
                update a;
            }
 
        } catch (Exception e) {
        }
    }
}

Thanks in advance,
If anybody know please tell me.

Thanks and Regards,
Sivasankari.M
Hello,

I am new to Salesforce and I have to integrate Salesforce wirh some CMS.

Basically the scenario is like this, presently date into website comes from another CMS.

I want to provide this service from Salesforce, such that Salesforce will provide data feed to CMS (using objects and records) and it will be available on website.

Please give suggestion of how to do this. Is there any app on AppExchange to do this or have to write Webservice for this?

Thanks in advance.
I am new in the lightning experience , can anyone suggest me how to cover these things plz reply as soon as possible ??
Hello

We have a customer who has a need for a cloud based CMS system, to compliment force.com pages serverd from salesforce. The customer does not want to build the entire website on force.com, only specific components/pages, to have served as embedded pages on the website/CMS.

So far, I have found a few options, and for one reason of another, may not be the best fit.

Wordpress - To many security vunerabilities. Upgrade process manual. Has to be served on dedicated server. 
Magento - Paying for to many used features for eCommerce. Site is not eCommerce.
Joomla - Upgrade process manual. Has to be served on dedicated server.

Can anyone recommend a CMS product (paid or open source) which they would consider for a website build for a SME (Small-Medium Enterprise business website with medium traffic)

Regards

Dave
Trying to do some basic addition between two datatables to simulate a shoping cart.

I want the tempCount to total into the Cart class. It looks like it should work. Not sure why it's throwing an error.

Apex:
public class StoreFront2 {
    public String message { get; set; }
    List<DisplayMerchandise> products;
    Map<Id, DisplayMerchandise> cart;

    public PageReference shop(){
        handleTheBasket();
        message = 'You bought: ';
        for (DisplayMerchandise p:products){
            if(p.count > 0){
               message += p.merchandise.name + ' (' + p.count + ') ' ;
               }
            }
        return null;
    }

    public void handleTheBasket(){
        for(DisplayMerchandise c : products){
            if(c.tempCount > 0){
            if(cart.containsKey(c.merchandise.Id)){
                
                cart.get(c.merchandise.Id).count += c.tempCount;
                
            }
            else{
                cart.put(c.merchandise.Id, c);
            } 
        
        }
        }
        
    }
    
    public Map<Id, DisplayMerchandise> getCart() {
        if(cart == null){
            cart = new Map<Id, DisplayMerchandise>{};
                }
       
        return cart;
    }

    public class DisplayMerchandise {
        public Merchandise__c merchandise{get; set;}
        public Decimal count{get; set;}
        public Decimal tempCount{get;set;}
        
        public DisplayMerchandise(Merchandise__c item){
            this.merchandise = item;
            
        }
    }

    public List<DisplayMerchandise> getProducts() {
        if (products == null){
            products = new List<DisplayMerchandise>{};

            for (Merchandise__c item :
            [SELECT id, name, description__c, price__c
            FROM Merchandise__c
            WHERE Total_Inventory__c > 0]) {
            products.add(new DisplayMerchandise(item));
            }
        }
        return products;
    }
}

Visualforce
<apex:page standardStylesheets="false" showHeader="false" sidebar="false" controller="StoreFront2">
  <apex:stylesheet value="{!URLFOR($Resource.styles)}"/>
  <h1>Store Front</h1>
  
  <apex:form >
      <apex:dataTable value="{!products}" var="pitem" rowClasses="odd,even">
          
          <apex:column headerValue="Product">
              <apex:outputText value="{!pitem.merchandise.name}" />
          </apex:column>
          <apex:column headervalue="Price">
              <apex:outputText value="{!pitem.merchandise.Price__c}" />
          </apex:column>
          <apex:column headerValue="#Items">
              <apex:inputText value="{!pitem.tempCount}"/>
          </apex:column>
   
      </apex:dataTable>
      
      <br/>
      <apex:commandButton action="{!shop}" value="Add to Cart" reRender="msg,cart" />
  </apex:form>
  
    <apex:outputPanel id="msg">{!message}</apex:outputPanel><br/>    
    <h1>Your Basket</h1>
<form>    
     <apex:dataTable id="cart" value="{!cart}" var="carti" rowClasses="odd,even">
          
          <apex:column headerValue="Product">
              <apex:outputText value="{!cart[carti].merchandise.name}" />
          </apex:column>
          <apex:column headervalue="Price">
              <apex:outputText value="{!cart[carti].merchandise.price__c}" />
          </apex:column>
          <apex:column headerValue="#Items">
              <apex:outputText value="{!cart[carti].count}"/>
          </apex:column>
   
      </apex:dataTable>
    </form>
    
  
</apex:page>

 
I'm trying to display a simple counter on my visualforce page that counts the number of shopping cart items.

Error: Unknown Property: "StoreFront.shopCart"

Apex:
 
public class StoreFrontController{

    list<DisplayMerchandise> products;     	
     
    integer shopCart;
    
    public list<DisplayMerchandise> getProducts(){
        if(products == null){
            products = new List<DisplayMerchandise>();
           
            for (Merchandise__c item : [SELECT Id, Name, Description__c, Price__c, Total_Inventory__c FROM Merchandise__c]) {
            	products.add(new DisplayMerchandise(item));
           
                
            }
                

            
        }         
       return products; 
    }
    
    public Integer getshopCart(){
        
        return shopcart;
    }
 
<apex:page standardStylesheets="false" showHeader="false" sidebar="false" controller="StoreFront">
  <apex:stylesheet value="{!URLFOR($Resource.styles)}"/>
  <h1>Store Front</h1>
  
  <apex:form >
      <apex:dataTable value="{!products}" var="pitem" rowClasses="odd,even">
          <apex:column headerValue="Product">
              <apex:outputText value="{!pitem.merchandise.name}" />
          </apex:column>
          <apex:column headervalue="Price">
              <apex:outputText value="{!pitem.merchandise.Price__c}" />
          </apex:column>
          <apex:column headerValue="#Items">
              <apex:inputText value="{!pitem.count}"/>
          </apex:column>
   
      </apex:dataTable>
      <br/>
      <apex:commandButton action="{!shop}" value="buy" reRender="msg" />
  </apex:form>
  
  <apex:outputPanel id="msg">{!message}</apex:outputPanel>

<apex:form>
    <apex:dataTable value="{!shopCart}" var='sq' rowClasses="odd,even">
    <apex:column>
    
        <apex:outputField value='{!sq.count}' />
        
    </apex:column>
    </apex:dataTable>
</apex:form>
  
  
  
  
</apex:page>

 
Hi,

For adding the item in a selectlist we do the following

for(String f :  FieldLabels)
        {
             selectedFieldsList.add(new selectOption(f,f));        
       
        }
and this works perfect.

Same way how to remove from the select list ? I dtried with the following things and got the errors

E.g : 1 : for(String f : selectedFields)
        {
             selectedFieldsList.remove(f);           
        }
ERROR :  Method does not exist or incorrect signature: [LIST<System.SelectOption>].remove(String)

for(integer i=0;i<selectedFields.Size();i++)
        {
                      selectedFieldsList.remove(selectedFields.Size());
        }
ERROR : LIST INDEX OUT OF BONDS

for(String f : selectedFields)
        {
         
           selectedFieldsList.remove(0); 
          
        }

here the items are deleted but , if i select 5 random items to delete, it is removing first 5 items not the selected one.
I am seeking community feedback on the best CMS solution to use with our Salesforce account. We are building a very large website, with standard functionality, and need a CMS to create pages and forms. Which systems exist that can be used with Salesforce (and/or Force.com), are they any good, and which are recommended? All feedback gratefully received. Thanks - Steve_at_Battersea

 

Hi

 

I used the below code for google map integration with salesforce  but the google map  not visible in my visual force page 

but when I use the  same code in note pad with out <apex:page> tag  its working .

anybody help me

 

 

 

<apex:page sidebar="false">

<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map_canvas { height: 100% }
</style>
<script type="text/javascript"
src="http://maps.googleapis.com/maps/api/js?sensor=false ">
</script>
<script type="text/javascript">
function initialize() {
var myOptions = {
center: new google.maps.LatLng(-34.397, 150.644),
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
}
</script>
</head>
<body onload="initialize()">

<div id="map_canvas" style="width:100%; height:100%"></div>
</body>
</html>


</apex:page>