mirror of
https://github.com/Viglino/ol-ext.git
synced 2026-01-18 17:11:52 +00:00
94 lines
3.1 KiB
HTML
94 lines
3.1 KiB
HTML
<!DOCTYPE html>
|
|
<!----------------------------------------------------------
|
|
|
|
Copyright (c) 2016 Jean-Marc VIGLINO,
|
|
released under CeCILL-B (french BSD like) licence: http://www.cecill.info/
|
|
|
|
------------------------------------------------------------>
|
|
<html>
|
|
<head>
|
|
<title>OL3-ext: Synchronize interaction</title>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
|
|
<meta name="description" content="Synchronize OL3 maps." />
|
|
<meta name="keywords" content="ol3, interaction, synchronize, map" />
|
|
|
|
<!-- jQuery -->
|
|
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.0.min.js"></script>
|
|
|
|
<!-- OL3 -->
|
|
<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>
|
|
|
|
<link rel="stylesheet" href="../interaction/synchronizeinteraction.css" />
|
|
<script type="text/javascript" src="../interaction/synchronizeinteraction.js"></script>
|
|
|
|
<link rel="stylesheet" href="style.css" />
|
|
<style>
|
|
#map2
|
|
{ background: #ddd none repeat scroll 0 0;
|
|
float: left;
|
|
margin-right: 1em;
|
|
}
|
|
</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>OL3-ext: Synchronize interaction</h1>
|
|
</a>
|
|
<p class="info">
|
|
The <i>ol.interaction.Synchronize</i> synchronize maps.
|
|
<br/>
|
|
An overlay is added on the synchronized map at the cursor position.
|
|
</p>
|
|
|
|
<!-- DIV for the map -->
|
|
<div id="map" style="width:600px; height:400px;"></div>
|
|
<div id="map2" style="width:600px; height:400px;"></div>
|
|
|
|
<script type="text/javascript">
|
|
// Layers
|
|
var mapbox = new ol.layer.Tile({
|
|
minResolution: 306,
|
|
source: new ol.source.XYZ(
|
|
{ url: 'https://{a-d}.tiles.mapbox.com/v3/mapbox.natural-earth-hypso-bathy/{z}/{x}/{y}.png',
|
|
attributions: [new ol.Attribution({ html: '© <a href="https://www.mapbox.com/map-feedback/">Mapbox</a> ' })]
|
|
})
|
|
});
|
|
var stamen = new ol.layer.Tile(
|
|
{ source: new ol.source.Stamen({ layer: 'watercolor' })
|
|
});
|
|
|
|
// The map
|
|
var map = new ol.Map
|
|
({ target: 'map',
|
|
view: new ol.View
|
|
({ zoom: 5,
|
|
center: [166326, 5992663]
|
|
}),
|
|
layers: [ new ol.layer.Tile(
|
|
{ source: new ol.source.Stamen({ layer: 'watercolor' })
|
|
})]
|
|
});
|
|
|
|
var map2 = new ol.Map
|
|
({ target: 'map2',
|
|
view: new ol.View
|
|
({ zoom: 5,
|
|
center: [166326, 5992663]
|
|
}),
|
|
layers: [ new ol.layer.Tile(
|
|
{ source: new ol.source.Stamen({ layer: 'toner' })
|
|
})]
|
|
});
|
|
|
|
// Synchronize the maps
|
|
map.addInteraction( new ol.interaction.Synchronize({ maps: [map2] }) );
|
|
map2.addInteraction( new ol.interaction.Synchronize({ maps: [map] }) );
|
|
|
|
</script>
|
|
|
|
</body>
|
|
</html> |