<div style="text-align:center;">
<div id="map" style="width:750px;height:500px;display:inline-block;"></div>
</div>
<script type="text/javascript">
var amaps = {{ amaps|json_encode()|raw }};
var icone = new L.icon({
iconUrl: 'https://cdn1.easyamap.fr/images/logo-easy-amap-icon.png',
iconSize: [50,60],
iconAnchor: [25,30]
});
var latmin = Number.POSITIVE_INFINITY;
var longmin = Number.POSITIVE_INFINITY;
var latmax = Number.NEGATIVE_INFINITY;
var longmax = Number.NEGATIVE_INFINITY;
var map = L.map('map');
var Stamen_Terrain = L.tileLayer('https://stamen-tiles-{s}.a.ssl.fastly.net/terrain/{z}/{x}/{y}.{ext}', {
attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> — Map data © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>',
subdomains: 'abcd',
minZoom: 0,
maxZoom: 18,
ext: 'png'
});
Stamen_Terrain.addTo(map);
for (var i in amaps)
{
if (amaps[i].length == 4)
{
var lat = amaps[i][1];
var lng = amaps[i][2];
var amap = amaps[i][0];
var town = amaps[i][3];
latmin = Math.min(latmin, lat);
latmax = Math.max(latmax, lat);
longmin = Math.min(longmin, lng);
longmax = Math.max(longmax, lng);
var latlng = new L.LatLng(lat, lng);
var marker = new L.marker(latlng, {
icon: icone
});
var popup = new L.Popup({closeButton: false});
popup.setContent(amap+"<br /><b>"+town+"</b>");
marker.bindPopup(popup);
/*marker.on('mouseover', marker.openPopup.bind(marker));*/
marker.addTo(map);
}
}
var bounds = new L.LatLngBounds([latmin, longmin],[latmax, longmax]);
map.fitBounds(bounds, {padding: [40,40]});
</script>