!if $opengeoloc!=yes
 $name_nogeoloc
 !exit
!endif
$name_geolocdesc
<link rel="stylesheet" href="//unpkg.com/leaflet@1.7.1/dist/leaflet.css"
   integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A=="
   crossorigin="">
<script src="//unpkg.com/leaflet@1.7.1/dist/leaflet.js"
   integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
   crossorigin=""></script>
<script src='//cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/0.4.0/leaflet.markercluster.js'></script>

<link rel="stylesheet" href="//unpkg.com/leaflet.markercluster@1.3.0/dist/MarkerCluster.css">
<link rel="stylesheet" href="//unpkg.com/leaflet.markercluster@1.3.0/dist/MarkerCluster.Default.css">
<script src="//unpkg.com/leaflet.markercluster@1.3.0/dist/leaflet.markercluster.js"></script>

<div id="mapid" style="width: 100%; max-width: 1000px; height: 800px; margin:.5em auto;"> </div>

<script>
  var map = L.map('mapid').setView([$Xserver, $Yserver], 9);
  L.tileLayer('https://{s}.tile.osm.org/{z}/{x}/{y}.png', {
    attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>',
    maxZoom: 18,
    tileSize: 512,
    zoomOffset: -1
  }).addTo(map);

  var LeafIcon = L.Icon.extend({
  options: {
    iconSize:     [12, 39],
    shadowSize:   [30, 41],
    iconAnchor:   [7, 39],
    shadowAnchor: [5, 39],
    popupAnchor:  [0, -39]
    }
    });
  //var ClassIcon = new LeafIcon({iconUrl: 'gifs/svg/iconeserver.svg'});
  var ServerIcon = new LeafIcon({iconUrl: 'gifs/svg/iconeserver.svg'});

  var markers = L.markerClusterGroup();
  !for k=1 to $[$nbclass-$serverloc]
    !let data=!record $k of wimshome/log/stat/class.geoloc
    !distribute item $data into town,nb,X,Y
    !if $nb>1
      !let r=0.001
    !else
      !let r=0
    !endif
    !for j=1 to $nb
      markers.addLayer(L.marker([$[$X+$r*cos($j*3.14/4)],$[$Y+$r*sin($j*3.14/4)]]).bindPopup("$town"));
      !if . notin $[$j/8]
        !let r=$[$r+0.001]
      !endif
    !next j
  !next k
  !if $serverloc=1
    !let data=!record -1 of wimshome/log/stat/class.geoloc
    !distribute item $data into town,nb,X,Y
    !if ($Xserver=$X and $Yserver=$Y) or $nb>1
      !let r=0.001
    !else
      !let r=0
    !endif
    !for j=1 to $nb
      markers.addLayer(L.marker([$[$X+$r*cos($j*3.14/4)],$[$Y+$r*sin($j*3.14/4)]]).bindPopup("$town"));
      !if . notin $[$j/8]
        !let r=$[$r+0.001]
      !endif
    !next j
    map.addLayer(markers);
    L.marker([$Xserver,$Yserver],{icon: ServerIcon}).bindPopup("WIMS $httpd_HTTP_HOST").addTo(map);
  !else
    map.addLayer(markers);
  !endif
</script>
