JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.3/leaflet.css">
<script src="http://cdn.leafletjs.com/leaflet-0.6.3/leaflet.js"></script>
<div id="map"></div>
<div id="overlay"></div>
CSS
html, body, #map {
width:100%;
height:100%;
margin:0;
margin-left:10%;
padding:0;
}
#overlay {
position:absolute;
width:30%;
height:100%;
left:0;
top:0;
background-color:rgba(255, 255, 255, 0.8);
}
.item {
border:1px, solid;
padding:2px;
margin:2px;
background-color:rgba(100, 100, 255, 0.5);
}
.active {
background-color:rgba(100, 100, 255, 0.9);
}
JavaScript
var markers = new Array();
var map = L.map('map', {
center: [48,14],
zoom: 7,
animate: true, duration: 1
});
L.tileLayer('http://{s}.wien.gv.at/basemap/geolandbasemap/normal/google3857/{z}/{y}/{x}.jpeg', {
attribution: 'http://www.basemap.at/',
subdomains: ['maps', 'maps1', 'maps2', 'maps3', 'maps4'],
maxZoom: 19
}).addTo(map);
map.on('click', onMapClick);
function onMarkerClick(e) {
$('div').removeClass('active');
$('div #' + e.target._leaflet_id).addClass('active');
map.panTo(e.target.getLatLng());
}
function onMapClick(e) {
var marker = new L.Marker(e.latlng);
marker.on('click', onMarkerClick);
map.addLayer(marker);
markers[marker._leaflet_id] = marker;
$('#overlay').append(
'<div class="item" id="' + marker._leaflet_id + '">Marker ' + marker._leaflet_id + ' - <a href="#" class="remove" id="' + marker._leaflet_id + '">remove</a></div>');
// Remove a marker
$('.remove').on("click", function () {
// Remove the marker
map.removeLayer(markers[$(this).attr('id')]);
// Remove the link
$(this).parent('div').remove();
});
$('.item').on("mouseover", function () {
$('div').removeClass('active');
$(this).addClass('active');
var mid = $(this).attr('id');
var LatLng = markers[mid].getLatLng();
map.panTo(LatLng);
});
}