Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add example showing scrolling content
- Loading branch information
1 parent
4342b97
commit 308d2a0
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>OpenLayers 3 - Popup - Scrolling content</title> | ||
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width"> | ||
<link rel="stylesheet" href="http://openlayers.org/en/v3.3.0/css/ol.css" /> | ||
<link rel="stylesheet" href="../src/ol3-popup.css" /> | ||
<link rel="stylesheet" href="popup.css" /> | ||
</head> | ||
<body> | ||
<div id="map"></div> | ||
<script src="http://openlayers.org/en/v3.3.0/build/ol.js"></script> | ||
<script src="../src/ol3-popup.js"></script> | ||
<script src="scroll.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
var map = new ol.Map({ | ||
target: 'map', | ||
layers: [ | ||
new ol.layer.Tile({ | ||
source: new ol.source.OSM() | ||
}) | ||
], | ||
view: new ol.View({ | ||
center: ol.proj.transform([-0.92, 52.96], 'EPSG:4326', 'EPSG:3857'), | ||
zoom: 6 | ||
}) | ||
}); | ||
|
||
var popup = new ol.Overlay.Popup(); | ||
map.addOverlay(popup); | ||
|
||
map.on('singleclick', function(evt) { | ||
var content = '<p>If the popup content is quite long then by default it will scroll vertically.</p>'; | ||
content += '<p>This behaviour together with the minimum width and maximum height can be changed by overriding the rules for the CSS class <code>.ol-popup-content</code> defined in <code>src/ol3-popup.css</code>.</p>'; | ||
content += '<hr />'; | ||
content += '<p><em>This text is here to demonstrate the content scrolling due to there being too much content to display :-)</em></p>'; | ||
popup.show(evt.coordinate, content); | ||
}); |