Menu
Close

Map Using WebComponent

Sample Implementation

    
      
      <html>
        <head>
          <title>Map Using WebComponent</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>
                    <my-app id='app'></my-app>
                        <script>
        var mapElement, map, marker, polyline;
        function initMap1() {
            customElements.define('my-app', class MyApp extends HTMLElement {
            constructor() {
                super();
                this.innerHTML = `<div id='map' style='height:450px; margin-top: -10px;'></div>`;
                mapElement = this.querySelector('#map');
            }
            connectedCallback() {
                map = new mappls.Map(mapElement, { center: [28.638698386592438, 77.27604556863412] });

                marker = new mappls.Marker({
                map: map,
                position: { lng: 77.26766496854583, lat: 28.551875786836902 },
                fitbounds: true,
                });

                let pts = [{ lng: 77.2673320122355, lat: 28.55193806197454 }, { lng: 77.26705599255376, lat: 28.5516912303532 }, { lng: 77.26812082953296, lat: 28.55159698968822 }];

                polyline = new mappls.Polyline({
                map: map,
                paths: pts,
                strokeColor: '#c1f4s6',
                strokeOpacity: 1.0,
                strokeWeight: 5,
                fitbounds: true
                });
            }

            });
        }
    </script>
        </body>
      </html>
      
      
      
    
  
Call at Mappls
Request Call Back

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

There's so much that Mappls MapmyIndia can do for your enterprise or individual requirements. Explore our website to learn more or request a callback/email if you'd like us to connect with you.

or