function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Arunkumar RArunkumar R 

Google Map Components in Salesforce

Hi Guys,

    Hope so many peoples integrated google map in visualforce page using the javascript. From Salesforce Spring'15 onwards, Map components are released. Some of the people may not aware about this.

Please find the below link it will helpful who don't know about this component..!

http://salesforcekings.blogspot.in/2015/03/of-us-already-known-about-thegoogle-map.html
Abilash Kosigi 8Abilash Kosigi 8
Hi all,

To add further to this, I have written a blog on leveraging Google charts in Salesforce. Please find below the link to it.

http://salesforceselflearn.blogspot.in/
Sugandhi VermaSugandhi Verma
hi Arunkumar,
I'm not able to Enable Maps and Location Services. Please give the detail on how to enable it. As i am not able to see App Setup in my account.
Peter LantzPeter Lantz
Awesome!!
RatanRatan
Salesforce Map and Location is not available in devloper org . It is available in Sandbox org..
RatanRatan
Google map with javascript..This page will get the current user location and it will create a record with location.

I have used this one with salesforce site. it is working awesome .. whoever visit my site, that person location saved in record.

 
<apex:page controller="RN_GeoWithJSController" wizard="true">
   <script type="text/javascript">
    window.onload=function(){getLocation()};
    function getLocation() {
    if (navigator.geolocation) {
        navigator.geolocation.watchPosition(showPosition);
    } else { 
        alert("Geolocation is not supported by this browser.");
    }
    }
    function showPosition(position) 
    {
        var lat = position.coords.latitude;
        var long = position.coords.longitude;
        document.getElementById('{!$Component.form.pb.hidden1}').value = lat;
        document.getElementById('{!$Component.form.pb.hidden2}').value = long;
        var latlon = lat+","+long;
        var img_url = "http://maps.googleapis.com/maps/api/staticmap?center="+latlon+"&zoom=14&size=800x300&sensor=false";
        document.getElementById('{!$Component.form.pb1}').innerHTML = "<img src='"+img_url+"'>";
        myFunction();
    }
    function myFunction() {
    
    var person = prompt("Please enter your name and be calm , We are tracking your location", "Harry Potter");
    if (person != null) {
        document.getElementById('{!$Component.form.pb.lanName}').value = person;
    }
    save();
}
    </script>
    <apex:form id="form">
    <apex:actionFunction name="save" action="{!saveLocation}" rerender="pb" />
        <apex:pageBlock id="pb">
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!saveLocation}" />
                <apex:commandButton value="Cancel" action="{!cancelLocation}"/>
            </apex:pageBlockButtons>
            Name:<apex:inputField value="{!objLongnLat.Name}" id="lanName"/>
            <apex:inputHidden value="{!objLongnLat.Location__Latitude__s}" id="hidden1"/>
            <apex:inputHidden value="{!objLongnLat.Location__Longitude__s}" id="hidden2"/>
        </apex:pageBlock>
        <apex:pageBlock id="pb1">
           
        </apex:pageBlock>
    </apex:form>
</apex:page>
 
public class RN_GeoWithJSController 
{
    public LongitudeAndLatitude__c objLongnLat {get;set;}
   
    public RN_GeoWithJSController()
    {
        objLongnLat = new LongitudeAndLatitude__c();
    }
    public PageReference saveLocation()
    {
        insert objLongnLat;
        string strlocation = objLongnLat.Location__Latitude__s +','+ objLongnLat.Location__Longitude__s;
        //PageReference acctPage = new ApexPages.StandardController(objLongnLat).view();
        PageReference acctPage = new PageReference('http://maps.googleapis.com/maps/api/staticmap?center='+strlocation+'&zoom=14&size=400x300&sensor=false');
        acctPage.setRedirect(true);
        return acctPage;
    }
    public PageReference cancelLocation()
    {
        PageReference acctPage = new PageReference('https://ap1.salesforce.com/');
        acctPage.setRedirect(true);
        return acctPage;
    }
}

https://01-developer-edition.ap1.force.com/Save/ (https://01-developer-edition.ap1.force.com/Save/" target="_parent)
Calvin NoronhaCalvin Noronha
My blog about easily adding Google maps to your VF page. 
Please ping me with any questions related to this. 
http://www.decodingthecloud.com/?p=68