单张有可能。在这里,我使用传单和jquery完成了滑动地图。
$(document).ready(function() {
var currentX = $("#viewport").width() / 2;
var resetPosition = function(x){
var pos = $(".leaflet-map-pane").position(),
coordLeft = ( - pos.top ) + "px, " + ( x - pos.left + 3 ) + "px, " + ( $("#viewport").height() - pos.top ) + "px, " + -pos.left + "px",
coordRight = ( - pos.top ) + "px, " + ( $("#viewport").width() - pos.left ) + "px, " + ( $("#viewport").height() - pos.top ) + "px, " + ( x - pos.left + 3 ) + "px";
$(".leaflet-layer:nth-child(3)").css("clip", "rect(" + coordLeft + ")");
$(".leaflet-layer:nth-child(2)").css("clip", "rect(" + coordRight + ")");
};
resetPosition(currentX);
map.on("move", function(){
resetPosition(currentX);
})
map.on("zoomend", function(){
resetPosition(currentX);
});
if( $.browser.msie && parseInt($.browser.version) < 9 ){
$("#vbar-divider").draggable({
drag: function(e){
currentX = $("#vbar-divider").position().left;
resetPosition(currentX);
},
axis: "x"
});
}else{
$("#vbar-divider").draggable({
drag: function(e){
currentX = $("#vbar-divider").position().left;
resetPosition(currentX);
$("#vbar-divider div").hide();
},
stop: function(){
$("#vbar-divider div").show();
},
axis: "x",
containment: "parent"
});
}
$('#vbar-divider').animate({
left: currentX,
},
500
);
});