mirror of
https://github.com/Viglino/ol-ext.git
synced 2026-01-25 17:36:21 +00:00
124 lines
3.7 KiB
HTML
124 lines
3.7 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<!----------------------------------------------------------
|
|
|
|
Copyright (c) 2016-2018 Jean-Marc VIGLINO,
|
|
released under CeCILL-B (french BSD like) licence: http://www.cecill.info/
|
|
|
|
------------------------------------------------------------>
|
|
<title>ol-ext: Magnify overlay</title>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
|
|
<meta name="description" content="iconic font and scalable vector icons for OL3" />
|
|
<meta name="keywords" content="ol3, overlay, magnify, glass, zoom" />
|
|
|
|
<!-- jQuery -->
|
|
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.0.min.js"></script>
|
|
|
|
<!-- Openlayers -->
|
|
<link rel="stylesheet" href="https://openlayers.org/en/master/css/ol.css" />
|
|
<script type="text/javascript" src="https://openlayers.org/en/master/build/ol.js"></script>
|
|
|
|
<!-- ol-ext -->
|
|
<link rel="stylesheet" href="../../dist/ol-ext.min.css" />
|
|
<script type="text/javascript" src="../../dist/ol-ext.js"></script>
|
|
|
|
<link rel="stylesheet" href="../style.css" />
|
|
|
|
<style>
|
|
.oview {
|
|
color: #fff;
|
|
background: #369;
|
|
padding: 0.5em;
|
|
display: inline-block;
|
|
margin-right: 0.5em;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<a href="https://github.com/Viglino/ol3-ext"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"></a>
|
|
|
|
<a href="../../index.html">
|
|
<h1>ol-ext: Magnify overlay</h1>
|
|
</a>
|
|
<div class="info">
|
|
The <i>ol.control.Magnify</i> add a "magnifying glass" effect to an OL3 map that displays
|
|
a portion of the map in a different zoom (and actually display different content).
|
|
<br/>
|
|
The magnifying glass can be placed outside the map's viewport using the target ad for a control.
|
|
|
|
</div>
|
|
|
|
<!-- the map -->
|
|
<div id="map" style="width:600px; height:400px;"></div>
|
|
|
|
<div>
|
|
<div class="oview">
|
|
External magnify
|
|
<div class="overview" style="width:150px; height:150px;"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="options">
|
|
Zoom offset: <input id="zoom" type="number" value="1" step="0.5" style="width:4em" />
|
|
<br />
|
|
Layer:
|
|
<select onchange="setOVLayer(this)">
|
|
<option value="0">OSM</option>
|
|
<option value="1" selected>Stamen</option>
|
|
</select>
|
|
</div>
|
|
|
|
<script type="text/javascript">
|
|
// The map
|
|
var map=new ol.Map
|
|
({
|
|
target: 'map',
|
|
view: new ol.View
|
|
({ zoom: 15,
|
|
center: [270148, 6247782]
|
|
}),
|
|
layers: [ new ol.layer.Tile({ source: new ol.source.Stamen({ layer: 'watercolor' }) }) ]
|
|
});
|
|
|
|
// Layers for the overview
|
|
var layers2 =
|
|
[ new ol.layer.Tile({ source: new ol.source.OSM() }),
|
|
new ol.layer.Tile(
|
|
{ source: new ol.source.Stamen({
|
|
layer: 'watercolor'
|
|
})
|
|
})
|
|
];
|
|
setOVLayer($(".options select"));
|
|
|
|
// New control on the map
|
|
var ov = new ol.Overlay.Magnify(
|
|
{ layers: layers2,
|
|
zoomOffset: $("#zoom").val(),
|
|
});
|
|
map.addOverlay(ov);
|
|
|
|
var ov2 = new ol.Overlay.Magnify(
|
|
{ layers: layers2,
|
|
target: $(".overview").get(0),
|
|
zoomOffset: $("#zoom").val(),
|
|
});
|
|
map.addOverlay(ov2);
|
|
|
|
// Options changes
|
|
function setOVLayer (e)
|
|
{ layers2[$(e).val()].setVisible(true);
|
|
layers2[1-$(e).val()].setVisible(false);
|
|
}
|
|
|
|
$("#zoom").on("change", function ()
|
|
{ ov.set("zoomOffset", Number($("#zoom").val()));
|
|
ov2.set("zoomOffset", Number($("#zoom").val()));
|
|
});
|
|
|
|
</script>
|
|
|
|
</body>
|
|
</html> |