leafletjs adding scrollable pop up? - Javascript Leaflet

Javascript examples for Leaflet:Pop up

Description

leafletjs adding scrollable pop up?

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <link rel="stylesheet" type="text/css" href="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css"> 
      <script type="text/javascript" src="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js"></script> 
      <style id="compiled-css" type="text/css">

#map {//from w w  w  . j a v a2s  . com
   height: 500px;
}


      </style> 
      <script type="text/javascript">
    window.onload=function(){
var map = L.map("map").setView([48.86, 2.35], 12);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
    attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
var initialContent = "test<br />Test<br />Test<br />Test<br />Test<br /><div id='extra'></div>";
var myPopup = L.popup({
   maxHeight: 100,
  closeOnClick: false,
  keepInView: true
}).setLatLng([48.86, 2.35]).setContent(initialContent).addTo(map).openOn(map);
var button = document.getElementById("button");
var extra = document.getElementById("extra");
button.addEventListener("click", function () {
  extra.innerHTML += "<br />Test";
  myPopup._updateLayout();
});
var button2 = document.getElementById("button2");
button2.addEventListener("click", function () {
   myPopup.setContent(initialContent);
});
    }

      </script> 
   </head> 
   <body> 
      <div id="map"></div> 
      <button id="button"> Add content to popup </button> 
      <button id="button2"> Reset popup content </button>  
   </body>
</html>

Related Tutorials