mirror of
https://expo.survex.com/repositories/expoweb/.git/
synced 2024-12-22 00:12:21 +00:00
148 lines
4.3 KiB
HTML
148 lines
4.3 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<link rel="stylesheet" href="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.3.0/css/ol.css" type="text/css">
|
|
<style>
|
|
.map {
|
|
height: 500px;
|
|
width: 100%;
|
|
}
|
|
#map .ol-zoom .ol-zoom-out {
|
|
margin-top: 204px;
|
|
}
|
|
#map .ol-zoomslider {
|
|
background-color: transparent;
|
|
top: 2.3em;
|
|
}
|
|
|
|
#map .ol-touch .ol-zoom .ol-zoom-out {
|
|
margin-top: 212px;
|
|
}
|
|
#map .ol-touch .ol-zoomslider {
|
|
top: 2.75em;
|
|
}
|
|
|
|
#map .ol-zoom-in.ol-has-tooltip:hover [role=tooltip],
|
|
#map .ol-zoom-in.ol-has-tooltip:focus [role=tooltip] {
|
|
top: 3px;
|
|
}
|
|
|
|
#map .ol-zoom-out.ol-has-tooltip:hover [role=tooltip],
|
|
#map .ol-zoom-out.ol-has-tooltip:focus [role=tooltip] {
|
|
top: 232px;
|
|
}
|
|
</style>
|
|
<script src="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.3.0/build/ol.js"></script>
|
|
<title>Expo prospecting slippy map</title>
|
|
</head>
|
|
<body>
|
|
<h2>Expo prospecting slippy map</h2>
|
|
<div id="map" class="map"></div>
|
|
<div id="info"> </div>
|
|
<script type="text/javascript">
|
|
// import Map from 'ol/Map.js';
|
|
// import View from 'ol/View.js';
|
|
// import GPX from 'ol/format/GPX.js';
|
|
// import {Tile as TileLayer, Vector as VectorLayer} from 'ol/layer.js';
|
|
// import BingMaps from 'ol/source/BingMaps.js';
|
|
// import VectorSource from 'ol/source/Vector.js';
|
|
// import {Circle as CircleStyle, Fill, Stroke, Style} from 'ol/style.js';
|
|
var lon = 13.8081;
|
|
var lat = 47.6776;
|
|
var zoom = 14;
|
|
|
|
var style = {
|
|
'Point': new ol.style.Style({
|
|
image: new ol.style.Circle({
|
|
fill: new ol.style.Fill({
|
|
color: 'rgba(255,255,0,0.4)'
|
|
}),
|
|
radius: 5,
|
|
stroke: new ol.style.Stroke({
|
|
color: '#ff0',
|
|
width: 1
|
|
})
|
|
})
|
|
}),
|
|
'LineString': new ol.style.Style({
|
|
stroke: new ol.style.Stroke({
|
|
color: '#f00',
|
|
width: 3
|
|
})
|
|
}),
|
|
'MultiLineString': new ol.style.Style({
|
|
stroke: new ol.style.Stroke({
|
|
color: '#0f0',
|
|
width: 3
|
|
})
|
|
})
|
|
};
|
|
|
|
var vector = new ol.layer.Vector({
|
|
source: new ol.source.Vector({
|
|
url: 'http://expo.survex.com/expofiles/gpslogs/essentials/essentials2019.gpx',
|
|
format: new ol.format.GPX()
|
|
}),
|
|
style: function(feature) {
|
|
return style[feature.getGeometry().getType()];
|
|
}
|
|
});
|
|
|
|
var map = new ol.Map({
|
|
//maxExtent: new ol.bounds(-20037508.34,-20037508.34,20037508.34, 20037508.34),
|
|
numZoomLevels: 18,
|
|
maxResolution: 156543,
|
|
units: 'meters',
|
|
//projection: new ol.projection("EPSG:900913"),
|
|
//displayProjection: new ol.projection("EPSG:4326"),
|
|
|
|
target: 'map',
|
|
layers: [
|
|
// new ol.layer.Tile({
|
|
// source: new ol.source.OSM()
|
|
// }),
|
|
new ol.layer.Tile({
|
|
source: new ol.source.OSM({
|
|
})
|
|
}),
|
|
vector
|
|
],
|
|
view: new ol.View({
|
|
center: ol.proj.fromLonLat([lon, lat]),
|
|
zoom: zoom
|
|
})
|
|
});
|
|
|
|
var displayFeatureInfo = function(pixel) {
|
|
var features = [];
|
|
map.forEachFeatureAtPixel(pixel, function(feature) {
|
|
features.push(feature);
|
|
});
|
|
if (features.length > 0) {
|
|
var info = [];
|
|
var i, ii;
|
|
for (i = 0, ii = features.length; i < ii; ++i) {
|
|
info.push(features[i].get('name'));
|
|
}
|
|
document.getElementById('info').innerHTML = info.join(', ') || '(unknown)';
|
|
map.getTarget().style.cursor = 'pointer';
|
|
} else {
|
|
document.getElementById('info').innerHTML = ' ';
|
|
map.getTarget().style.cursor = '';
|
|
}
|
|
};
|
|
|
|
map.on('pointermove', function(evt) {
|
|
if (evt.dragging) {
|
|
return;
|
|
}
|
|
var pixel = map.getEventPixel(evt.originalEvent);
|
|
displayFeatureInfo(pixel);
|
|
});
|
|
|
|
map.on('click', function(evt) {
|
|
displayFeatureInfo(evt.pixel);
|
|
});
|
|
</script>
|
|
</body>
|
|
</html> |