draw markers of different sizes - Javascript Leaflet

Javascript examples for Leaflet:Marker

Description

draw markers of different sizes

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Leaflet Different Icon Sizes</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.js"></script> 
      <script type="text/javascript" src="http://cdn.leafletjs.com/leaflet-0.4.5/leaflet.js"></script> 
      <link rel="stylesheet" type="text/css" href="http://cdn.leafletjs.com/leaflet-0.4.5/leaflet.css"> 
      <script type="text/javascript">
    $(window).load(function(){/*  ww  w  . j a v  a  2s  .com*/
var planes = [
            ["7C6B07",-40.99497,174.50808, 5, 5],
            ["7C6B38",-41.30269,173.63696, 10, 10],
            ["7C6CA1",-41.49413,173.5421, 15, 5],
            ["7C6CA2",-40.98585,174.50659, 15, 15],
            ["C81D9D",-40.93163,173.81726, 20, 5],
            ["C82009",-41.5183,174.78081, 20, 10],
            ["C82081",-41.42079,173.5783, 5, 15],
            ["C820AB",-42.08414,173.96632, 5, 9],
            ["C820B6",-41.51285,173.53274, 7, 12]
            ];
            var map = L.map('map').setView([-41.3058, 174.82082], 8);
            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 = 0; i < planes.length; i++) {
                var myIcon = L.icon({
                    iconUrl: 'http://leafletjs.com/dist/images/marker-icon.png',
                    iconSize: [planes[i][3], planes[i][4]]
                });
                marker = new L.marker([planes[i][1],planes[i][2]], {icon: myIcon})
                    .bindPopup(planes[i][0])
                    .addTo(map);
            }
    });

      </script> 
   </head> 
   <body> 
      <div id="map" style="width:500px;height:400px;"></div>  
   </body>
</html>

Related Tutorials