Merge pull request #498 from mtmail/move-mouse-position-info-on-map

HTML map: new button -show map bounds-
This commit is contained in:
Sarah Hoffmann 2016-08-24 22:19:48 +02:00 committed by GitHub
commit cd6dcfa574
4 changed files with 40 additions and 3 deletions

View File

@ -96,7 +96,10 @@
<?php } ?>
<div id="map-wrapper">
<div id="map-position"></div>
<div id="map-position">
<div id="map-position-inner"></div>
<div id="map-position-close"><a href="#">hide</a></div>
</div>
<div id="map"></div>
</div>

View File

@ -81,7 +81,10 @@
<?php } ?>
<div id="map-wrapper">
<div id="map-position"></div>
<div id="map-position">
<div id="map-position-inner"></div>
<div id="map-position-close"><a href="#">hide</a></div>
</div>
<div id="map"></div>
</div>

View File

@ -51,6 +51,7 @@ form label {
}
#map-position {
display: none;
position: absolute;
top: 0;
right: 20px;
@ -61,6 +62,10 @@ form label {
z-index: 100;
}
#map-position-close {
text-align: right;
}
.result {
font-size: 0.8em;
margin: 5px;

View File

@ -29,6 +29,32 @@ jQuery(document).on('ready', function(){
cm.addTo(map);
}
var MapPositionControl = L.Control.extend({
options: {
position: 'topright'
},
onAdd: function (map) {
var container = L.DomUtil.create('div', 'my-custom-control');
$(container).text('show map bounds').addClass('leaflet-bar btn btn-sm btn-default').on('click', function(e){
e.preventDefault();
e.stopPropagation();
$('#map-position').show();
$(container).hide();
});
$('#map-position-close a').on('click', function(e){
e.preventDefault();
e.stopPropagation();
$('#map-position').hide();
$(container).show();
});
return container;
}
});
map.addControl(new MapPositionControl());
function display_map_position(mouse_lat_lng){
@ -45,7 +71,7 @@ jQuery(document).on('ready', function(){
html_viewbox = "viewbox: " + map_viewbox_as_string();
$('#map-position').html([html_center,html_zoom,html_viewbox,html_click,html_mouse].join('<br/>'));
$('#map-position-inner').html([html_center,html_zoom,html_viewbox,html_click,html_mouse].join('<br/>'));
$('input#use_viewbox').trigger('change');
}