I am currently working on an interactive leaflet map. I managed to display markers from a database via php (create an array). Now I want users to create markers with a click on the map. To add a marker with a click is not the problem, nor to delete the marker again. I have created two buttons in a popup (bind to the created marker). While one marker deletes the marker, the other button shall open a form.
I want this form to be displayed with jquery overlay function (in front of the map and the popup). I managed to open the overlay content, when the link is outside the leaflet-script. But I have no idea how to do open the overlay content from inside the leaflet-script. It just doesn't work!
Does anybody had kind of the same problem? I am not very sure if that will work at the end, I build my script step by step. But an overlay function would be very nice to have.
Hope this picture explains my problem.
<html>
<head>
<title>Marker Leaflet Map</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7/leaflet.css"/>
<script src="http://cdn.jquerytools.org/1.2.5/jquery.tools.min.js"></script>
<style>
html, body, #map {
height: 100%;
width: 100%;
}
html, body {
padding:0px;
margin:0px;
background: rgb(169,219,128); /* Old browsers */
}
/* the overlayed element */
.simple_overlay {
display:none;
/* place overlay on top of other elements */
z-index:100000;
/* styling */
background-color:#333;
border:1px solid #666;
/* CSS3 styling for latest browsers */
-moz-box-shadow:0 0 90px 5px #000;
-webkit-box-shadow: 0 0 90px #000;
}
/* close button positioned on upper right corner */
.simple_overlay .close {
background-image:url(http://demo.staticfloat.com/overlay/close.png);
position:absolute;
right:-15px;
top:-15px;
cursor:pointer;
height:35px;
width:35px;
}
</style>
<script>
$(document).ready(function() {
$('#test1').fadeOut();
$("img[rel]").overlay();
});
</script>
</head>
<body>
<div id="map" style="width: 100%; height: 100%"></div>
<script src="http://cdn.leafletjs.com/leaflet-0.7/leaflet.js">
</script>
<script>
var map = L.map('map').setView([-41.2858, 174.78682], 14);
mapLink = '<a href="http://openstreetmap.org">OpenStreetMap</a>';
L.tileLayer(
'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: 'Map data © ' + mapLink,
maxZoom: 18,
}).addTo(map);
var marker = L.marker([-41.29042, 174.78219])
.bindPopup('<img src="http://tinyurl.com/pb9esy2" rel="#test1" alt="" width="100px">')
.openPopup()
.addTo(map);
</script>
<div style="position: absolute; right:100px; top:20px">
<img src="http://tinyurl.com/pb9esy2" rel="#test1" alt="" width="100px">
</div>
<div class="simple_overlay" id="test1" style="display:none;background:#2f2f2f;padding:20px;">
<img src="http://tinyurl.com/pb9esy2" rel="#test1" alt="" width="100px">" alt=""/>
<br/>
</div>
</body>
</html>