mirror of
https://github.com/Viglino/ol-ext.git
synced 2026-01-18 16:42:47 +00:00
164 lines
5.0 KiB
HTML
164 lines
5.0 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<!--
|
|
Copyright (c) 2017-2018 Jean-Marc VIGLINO,
|
|
released under CeCILL-B (french BSD like) licence: http://www.cecill.info/
|
|
-->
|
|
<title>ol-ext: GeoRSS source</title>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
|
|
<meta name="description" content="WikiCommons layer for OL3" />
|
|
<meta name="keywords" content="ol, layer, source, vector, GeoRSS" />
|
|
|
|
<!-- FontAwesome -->
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
|
|
|
<!-- jQuery -->
|
|
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.0.min.js"></script>
|
|
|
|
<!-- Openlayers -->
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/ol@latest/ol.css" />
|
|
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ol@latest/dist/ol.js"></script>
|
|
|
|
|
|
<!-- ol-ext -->
|
|
<link rel="stylesheet" href="../../dist/ol-ext.css" />
|
|
<script type="text/javascript" src="../../dist/ol-ext.js"></script>
|
|
<!-- Pointer events polyfill for old browsers, see https://caniuse.com/#feat=pointer -->
|
|
<script src="https://unpkg.com/elm-pep"></script>
|
|
|
|
<!-- ol-ext maki and fontawesome defintions used in fontsymbol -->
|
|
<script type="text/javascript" src="../../dist/extra/FontAwesomeDef.js"></script>
|
|
<!-- filesaver-js -->
|
|
<script type="text/javascript" src="https://cdn.rawgit.com/eligrey/FileSaver.js/aa9f4e0e/FileSaver.min.js"></script>
|
|
|
|
<link rel="stylesheet" href="../style.css" />
|
|
<style>
|
|
|
|
#map {
|
|
width: 600px;
|
|
height: 400px;
|
|
}
|
|
.fullscreen #map {
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
z-index: 10;
|
|
}
|
|
.fullscreen .options.top {
|
|
position: fixed;
|
|
top: 0;
|
|
right: 0;
|
|
z-index:10000;
|
|
}
|
|
|
|
</style>
|
|
</head>
|
|
<body >
|
|
<a href="https://github.com/Viglino/ol-ext" class="icss-github-corner"><i></i></a>
|
|
|
|
<i class="fa fa-fire" style="position: absolute; left: -100px;"></i>
|
|
<a href="../../index.html">
|
|
<h1>ol-ext: GeoRSS source</h1>
|
|
</a>
|
|
<p class="info">
|
|
<i>ol/source/GeoRSS</i> is a vector source to load a <a href="http://www.georss.org/">GeoRSS feed</a>.
|
|
<br/>
|
|
Find <a href="https://emergency.copernicus.eu/mapping/georss-feeds-aggregated">GeoRSS examples</a>.
|
|
</p>
|
|
|
|
<!-- DIV pour la carte -->
|
|
<div id="map"></div>
|
|
<div class="options top">
|
|
<button onclick="$('body').toggleClass('fullscreen'); map.updateSize();">fullscreen</button>
|
|
</div>
|
|
<div id ="select" class="options" >Select an item.</div>
|
|
|
|
<script type="text/javascript">
|
|
// The map
|
|
var map = new ol.Map ({
|
|
target: 'map',
|
|
view: new ol.View ({
|
|
zoom: 2,
|
|
center: [-1089966, 4552499]
|
|
}),
|
|
layers: [ new ol.layer.Tile({ name:"OSM", source: new ol.source.OSM() })]
|
|
});
|
|
|
|
// WikiCommons layer source
|
|
var vectorSource = new ol.source.GeoRSS ({
|
|
url: 'https://earthquakes.bgs.ac.uk/feeds/MhSeismology.xml',
|
|
attributions: ['<a href="https://www.bgs.ac.uk/data/services/georss.html">BGS</a>']
|
|
//url: 'https://emergency.copernicus.eu/mapping/activations-risk-and-recovery/feed',
|
|
//attributions: ['<a href="https://emergency.copernicus.eu/mapping/">Copernicus EMS</a>']
|
|
//url: 'https://emergency.copernicus.eu/mapping/list-of-components/EMSN053/feed',
|
|
});
|
|
|
|
var getStyle = function(f) {
|
|
var glyph = /fire/i.test(f.get('category')) ? 'fa-fire' :
|
|
/flood/i.test(f.get('category')) ? 'fa-tint' :
|
|
/wind/i.test(f.get('category')) ? 'fa-forumbee' :
|
|
/storm/i.test(f.get('category')) ? 'fa-flash' :
|
|
/human/i.test(f.get('category')) ? 'fa-heartbeat' :
|
|
/quake/i.test(f.get('category')) ? 'fa-bullseye' :
|
|
/other/i.test(f.get('category')) ? 'fa-gear' :
|
|
'fa-shield';
|
|
return new ol.style.Style({
|
|
image: new ol.style.FontSymbol({
|
|
form: 'marker',
|
|
glyph: glyph,
|
|
radius: 16,
|
|
offsetY: -8,
|
|
fill: new ol.style.Fill({
|
|
color: /tint|bee/.test(glyph) ? 'cyan' : /eye|beat/.test(glyph) ? 'lightgreen' : 'orange'
|
|
}),
|
|
stroke: new ol.style.Stroke({
|
|
color: /tint|bee/.test(glyph) ? 'blue' : /eye|beat/.test(glyph) ? 'darkgreen' : 'red',
|
|
width: 1.5
|
|
})
|
|
|
|
})
|
|
});
|
|
};
|
|
var vector = new ol.layer.Vector({
|
|
name: 'GeoRSS',
|
|
source: vectorSource,
|
|
// y ordering
|
|
renderOrder: ol.ordering.yOrdering(),
|
|
style: getStyle
|
|
});
|
|
|
|
map.addLayer(vector);
|
|
|
|
// Control Select
|
|
var select = new ol.interaction.Select({})
|
|
map.addInteraction(select);
|
|
|
|
var popup = new ol.Overlay.PopupFeature({
|
|
popupClass: 'default anim',
|
|
select: select,
|
|
canFix: true
|
|
});
|
|
map.addOverlay (popup);
|
|
|
|
|
|
// Save resulting layer
|
|
function save() {
|
|
var format = new ol.format.GeoJSON();
|
|
var data = format.writeFeatures(vectorSource.getFeatures(), {
|
|
dataProjection: 'EPSG:4326',
|
|
featureProjection: map.getView().getProjection()
|
|
});
|
|
var blob = new Blob([data], {type: "text/plain;charset=utf-8"});
|
|
saveAs(blob, "georss.geojson");
|
|
}
|
|
|
|
</script>
|
|
<!-- -->
|
|
</body>
|
|
</html> |