Menu
Close

Advance Cluster Marker

Sample Implementation

    
      
      <html>
        <head>
          <title>Advance Cluster Marker</title>
          <meta name="viewport" content="initial-scale=1.0">
          <meta charset="utf-8">
          <style>
          html,
          body,
          #map {
            margin: 0;
            padding: 0;
            width: 100%;
            height: 100vh;
          }
          </style>
             <script src="https://apis.mappls.com/advancedmaps/api/<Token>/map_sdk?layer=vector&v=3.0&callback=initMap1" defer async></script>
            </head>
        <body>

                    <div id="map"></div>
                        <script>
        /*Map Initialization*/
        var map,marker;
        function initMap1() {
            map = new mappls.Map('map', {
                center: [28.61, 77.23],
                zoomControl: true,
                zoom:8,
                location: true,
            });
            map.on('load', function() {
                var all_data = [];
                for (let i = 0; i < 1000; i++) {
                    let lt = randomNumber(26, 29);
                    let ln = randomNumber(76, 79);
                    obj = {
                        "type": "Feature",
                        "properties": {
                            "htmlPopup": "MapmyIndia "+i+"", "icon-size1": 0.55
                        },
                        "geometry": {
                            "type": "Point",
                            "coordinates": [lt, ln]
                        }
                    }
                    all_data.push(obj);
                }
                marker = new mappls.Marker({
                    map: map,
                    position: {
                        "id": "ravi",
                        "type": "FeatureCollection",
                        "features": all_data
                    },
                    fitbounds: true,
                    icon: 'https://apis.mapmyindia.com/map_v3/2.png',
                    offset: [0, -40],
                    draggable: false,
                    clustersOptions: {
                        background: [
                            [2, 'green'],
                            [5, 'red'],
                            [10, 'yellow'],
                            [20, 'orange'],
                            [35, 'blue']
                        ], // steps in background color (in pixels)
                        maxZoom: 7, // that zoom for split cluster circle 
                        radius: [
                            [2, 15],
                            [5, 20],
                            [10, 30],
                            [20, 40],
                            [35, 50],
                        ] // steps in cluster radius (in pixels)
                    }
                    /*Using steps expressions - introduced in background color, and radius - Produces discrete,
                    stepped results by evaluating a piecewise-constant function defined by pairs of input and 
                    output values ("stops"). Stop inputs must be numeric literals in strictly ascending order. */
                });
            })
        }
        // generate random lat lng    
        function randomNumber(min, max) {
            return Math.random() * (max - min) + min
        }
    </script>
        </body>
      </html>
      
      
      
    
  
Call at Mappls
Product release

Personalisation SDK, by Mappls, is India's first O2O engagement tool that can 3X your customer engagement, retention and conversion.

Boost your businesses with Mappls’ industry-leading optimisation APIs and SDKs to bring the best and most efficient ways to deliver goods, save time and increase profits.

or