Adding popup to full-screen example
This commit is contained in:
+78
-32
@@ -1,34 +1,80 @@
|
|||||||
<!doctype html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
|
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
html, body, #map {
|
html, body, #map {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
.overlay {
|
.overlay {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
font-family: Verdana, Arial, Helvetica, sans-serif;
|
||||||
.ol-overlaycontainer .overlay {
|
font-size: 10pt;
|
||||||
display: block;
|
}
|
||||||
}
|
.ol-overlaycontainer .overlay {
|
||||||
#vienna {
|
display: block;
|
||||||
font-family: Verdana, Arial, Helvetica, sans-serif;
|
}
|
||||||
font-size: 11pt;
|
#vienna {
|
||||||
color: white;
|
text-decoration: none;
|
||||||
text-shadow: black 0.1em 0.1em 0.2em;
|
color: white;
|
||||||
}
|
font-size: 11pt;
|
||||||
</style>
|
font-weight: bold;
|
||||||
<link rel="stylesheet" href="../css/ol.css" type="text/css">
|
text-shadow: black 0.1em 0.1em 0.2em;
|
||||||
<title>ol3 full-screen demo</title>
|
}
|
||||||
</head>
|
#popup {
|
||||||
<body>
|
width: 200px;
|
||||||
<div id="map">
|
margin-left: -107px;
|
||||||
<div class="overlay" id="vienna">Vienna</div>
|
margin-bottom: 12px;
|
||||||
</div>
|
}
|
||||||
<script src="loader.js?id=full-screen" type="text/javascript"></script>
|
|
||||||
</body>
|
|
||||||
|
/* Popup CSS generated with http://cssarrowplease.com/ */
|
||||||
|
|
||||||
|
.arrow_box {
|
||||||
|
position: relative;
|
||||||
|
background: #88b7d5;
|
||||||
|
border: 2px solid #c2e1f5;
|
||||||
|
border-radius: 5px;
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
.arrow_box:after, .arrow_box:before {
|
||||||
|
top: 100%;
|
||||||
|
border: solid transparent;
|
||||||
|
content: " ";
|
||||||
|
height: 0;
|
||||||
|
width: 0;
|
||||||
|
position: absolute;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.arrow_box:after {
|
||||||
|
border-color: rgba(136, 183, 213, 0);
|
||||||
|
border-top-color: #88b7d5;
|
||||||
|
border-width: 10px;
|
||||||
|
left: 50%;
|
||||||
|
margin-left: -10px;
|
||||||
|
}
|
||||||
|
.arrow_box:before {
|
||||||
|
border-color: rgba(194, 225, 245, 0);
|
||||||
|
border-top-color: #c2e1f5;
|
||||||
|
border-width: 13px;
|
||||||
|
left: 50%;
|
||||||
|
margin-left: -13px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<link rel="stylesheet" href="../css/ol.css" type="text/css">
|
||||||
|
<title>ol3 full-screen demo</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="map">
|
||||||
|
<!-- Clickable label for Vienna -->
|
||||||
|
<a class="overlay" id="vienna" target="_blank" href="http://en.wikipedia.org/wiki/Vienna">Vienna</a>
|
||||||
|
<!-- Popup -->
|
||||||
|
<div class="overlay arrow_box" id="popup"></div></span>
|
||||||
|
</div>
|
||||||
|
<script src="loader.js?id=full-screen" type="text/javascript"></script>
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ goog.require('goog.debug.Logger');
|
|||||||
goog.require('goog.debug.Logger.Level');
|
goog.require('goog.debug.Logger.Level');
|
||||||
goog.require('ol.Collection');
|
goog.require('ol.Collection');
|
||||||
goog.require('ol.Coordinate');
|
goog.require('ol.Coordinate');
|
||||||
|
goog.require('ol.CoordinateFormat');
|
||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.MapOptions'); // FIXME this should not be required
|
goog.require('ol.MapOptions'); // FIXME this should not be required
|
||||||
goog.require('ol.overlay.Overlay');
|
goog.require('ol.overlay.Overlay');
|
||||||
@@ -23,9 +24,25 @@ var map = new ol.Map(document.getElementById('map'), {
|
|||||||
layers: new ol.Collection([layer]),
|
layers: new ol.Collection([layer]),
|
||||||
zoom: 2
|
zoom: 2
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Vienna label
|
||||||
var vienna = new ol.overlay.Overlay({
|
var vienna = new ol.overlay.Overlay({
|
||||||
map: map,
|
map: map,
|
||||||
coordinate: ol.Projection.transformWithCodes(
|
coordinate: ol.Projection.transformWithCodes(
|
||||||
new ol.Coordinate(16, 48), 'EPSG:4326', 'EPSG:3857'),
|
new ol.Coordinate(16, 48), 'EPSG:4326', 'EPSG:3857'),
|
||||||
element: document.getElementById('vienna')
|
element: document.getElementById('vienna')
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Popup showing the position the user clicked
|
||||||
|
var popup = new ol.overlay.Overlay({
|
||||||
|
map: map,
|
||||||
|
element: document.getElementById('popup')
|
||||||
|
});
|
||||||
|
map.addEventListener('click', function(evt) {
|
||||||
|
var coordinate = evt.getCoordinate();
|
||||||
|
popup.getElement().innerHTML =
|
||||||
|
'Welcome to ol3. The location you clicked was<br>' +
|
||||||
|
ol.CoordinateFormat.hdms(ol.Projection.transformWithCodes(
|
||||||
|
coordinate, 'EPSG:3857', 'EPSG:4326'));
|
||||||
|
popup.setCoordinate(evt.getCoordinate());
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user