Toggle Side Panel

  • Home
  • Articles
    • All Articles
    • Blogs
    • Videos
    • Infographics
  • Consultants
    • Salesforce Product Expertise
      • Top Salesforce ConsultantsTop Salesforce Consultants
      • Marketing Cloud ConsultantsMarketing Cloud Consultants
      • Service Cloud ConsultantsService Cloud Consultants
      • Experience Cloud ConsultantsExperience Cloud Consultants
      • Analytics Cloud ConsultantsAnalytics Cloud Consultants
    • Salesforce Industry Expertise
      • Non-Profit Cloud ConsultantsNon-Profit Cloud Consultants
      • Financial Service Cloud ConsultantsFinancial Service Cloud Consultants
      • Health Cloud ConsultantsHealth Cloud Consultants
      • Commerce Cloud ConsultantsCommerce Cloud Consultants
      • Manufacturing Cloud ConsultantsManufacturing Cloud Consultants
    • Salesforce Experts by Location
      • USATop Salesforce Consultants in USA
      • IndiaTop Salesforce Consultants in India
      • AustraliaTop Salesforce Consultants in Australia
      • United KingdomTop Salesforce Consultants in UK
      • CanadaTop Salesforce Consultants in Canada
  • Webinars
  • Contact Us
  • Discussions
More options
    Sign in Sign up
    • Home
    • Articles
      • All Articles
      • Blogs
      • Videos
      • Infographics
    • Consultants
      • Salesforce Product Expertise
        • Top Salesforce ConsultantsTop Salesforce Consultants
        • Marketing Cloud ConsultantsMarketing Cloud Consultants
        • Service Cloud ConsultantsService Cloud Consultants
        • Experience Cloud ConsultantsExperience Cloud Consultants
        • Analytics Cloud ConsultantsAnalytics Cloud Consultants
      • Salesforce Industry Expertise
        • Non-Profit Cloud ConsultantsNon-Profit Cloud Consultants
        • Financial Service Cloud ConsultantsFinancial Service Cloud Consultants
        • Health Cloud ConsultantsHealth Cloud Consultants
        • Commerce Cloud ConsultantsCommerce Cloud Consultants
        • Manufacturing Cloud ConsultantsManufacturing Cloud Consultants
      • Salesforce Experts by Location
        • USATop Salesforce Consultants in USA
        • IndiaTop Salesforce Consultants in India
        • AustraliaTop Salesforce Consultants in Australia
        • United KingdomTop Salesforce Consultants in UK
        • CanadaTop Salesforce Consultants in Canada
    • Webinars
    • Contact Us
    • Discussions
    Close search
    How to use Leaflet Map in Salesforce?

    How to use Leaflet Map in Salesforce?

    Parv Shekhar Singh May 31, 2018
    11,106  Views

    Leaflet Map:

    Leaflet is the leading open-source JavaScript library for mobile-friendly interactive maps. The leaflet is designed with simplicity, performance, and usability in mind.

    Let’s understand the use of Marker icons, Leaflet Bubble Map icons. To add marker icons in Leaflet Map, use the below snippet of code in a script tag in your Visualforce page:

    var map = L.map('map').setView([28.38, 77.12], 10);
    mapLink = '<a href="http://openstreetmap.org">OpenStreetMap</a>';
    L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {attribution: '© ' + mapLink + ' Contributors', maxZoom: 18,}).addTo(map);
    L.marker([51.509, -0.08],{color : 'red',fillColor : '#f03', fillOpacity: 0.5,radius :700}).addTo(map)
    .bindPopup('A main message')
    .openPopup();

    Leaflet_marker 1

    Add the below CDN to your page to easily access the Stylesheets and scripts :

    Content Delivery Network (CDN):

    A Content Delivery Network (CDN) is a system of computers that exist all over the world and cache files for users to access. CDNs can greatly reduce the load time of a page by offering files at a higher bandwidth from a server that is physically closer to your visitor than your web server might be.

    <apex:stylesheet value=”https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.3/leaflet.css” />
    <apex:includescript value=”https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.3/leaflet.js” />

    Now, let focus on Bubble marker icon, here’s the snippet of code we can use to show bubble maker:

    <apex:page>
        <apex:stylesheet value=”https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.3/leaflet.css” />
        <apex:includescript value=”https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.3/leaflet.js” />
        <div id=”map” style=”width: 600px; height: 400px”>
        </div>
        <head>
            <script>
                var jsondata=[ { ‘x’: ”, ‘y’: ”, ‘z’: ” } ];
                var arr4 = new Array(jsondata);
                <apex:repeat value=”{!listofAccount}” var=”accId”>
                    arr4.push(‘{!accId.Latitude__c}’,'{!accId.Longitude__c}’,'{!accId.Circle_Size__c}’);
                </apex:repeat>
                var size = (arr4.length-1)/3 + 1;
                alert(‘#### elements : ‘ +size);
                var map = L.map(‘map’).setView([28.38, 77.12], 10);
                mapLink = ‘<a href=”http://openstreetmap.org”>OpenStreetMap</a>’;
                L.tileLayer(‘http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png’,{attribution: ‘&copy; ‘ + mapLink + ‘ Contributors’, maxZoom: 18,}).addTo(map);
                for(var i=1; i<size; i++){
                    L.circle([arr4[(i-1)*3 + 1],
                    arr4[(i-1)*3 + 2]],
                    color : ‘red’,fillColor : ‘#f03’, fillOpacity: 0.5,radius : arr4[(i-1)*3 + 3]}).addTo(map) .bindPopup(‘A main message’) .openPopup();
                }
            </script>
        </head>
    </apex:page>
    

    Below is the screenshot for bubble map :

    leaflet_bubble

     

    Categories: Salesforce Implementation
    Tagged: CDN, Content Delivery Network, Google Maps in Salesforce, Leaflet, Leaflet Map, Maps in Salesforce, Multiple Accounts, Multiple Records, Salesforce Account, Salesforce Visualforce Pages
    salesforce consultants
    Footer Forcetalks logo

    support@forcetalks.com

    • twitterx

    Quick Links

    Advertise with Us

    Salesforce® Articles

    Dreamforce 2023

    Top Salesforce® Bloggers 2023

    Top Salesforce Consultants

    Get Listed

    Company

    Contact Us

    About Us

    Privacy Policy

    Terms & Conditions

    InsightHub

    Salesforce Blogs

    Salesforce Videos

    Salesforce Groups

    Salesforce Jobs

    © 2026 - Forcetalks ● All Rights Reserved

    Salesforce® is a trademark of Salesforce® Inc. No claim is made to the exclusive right to use “Salesforce”. Any services offered within the Forcetalks website/app are not sponsored or endorsed by Salesforce®.

    Try AuditMyCRM - It is a Salesforce CRM Audit tool which comprehensively scans your Salesforce org and gives you the list of errors or warnings you need to take care of.
    We use cookies to enhance your browsing experience. Please see our privacy policy if you'd like more information on our use of cookies.