Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
4009cem/index.html
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
188 lines (185 sloc)
9.16 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Location Tracker</title> | |
<script> | |
var arrayColumn = (arr, n) => arr.map(x => x[n]) | |
var colorArray = ['#FF6633', '#FFB399', '#FF33FF', '#FFFF99', '#00B3E6', | |
'#E6B333', '#3366E6', '#999966', '#99FF99', '#B34D4D', | |
'#80B300', '#809900', '#E6B3B3', '#6680B3', '#66991A', | |
'#FF99E6', '#CCFF1A', '#FF1A66', '#E6331A', '#33FFCC', | |
'#66994D', '#B366CC', '#4D8000', '#B33300', '#CC80CC', | |
'#66664D', '#991AFF', '#E666FF', '#4DB3FF', '#1AB399', | |
'#E666B3', '#33991A', '#CC9999', '#B3B31A', '#00E680', | |
'#4D8066', '#809980', '#E6FF80', '#1AFF33', '#999933', | |
'#FF3380', '#CCCC00', '#66E64D', '#4D80CC', '#9900B3', | |
'#E64D66', '#4DB380', '#FF4D4D', '#99E6E6', '#6666FF']; | |
</script> | |
<style> | |
table { | |
width: 100%; | |
} | |
th, td { | |
padding: 8px; | |
} | |
tr:nth-child(even) {background-color: #f2f2f2;} | |
</style> | |
<link rel="stylesheet" href="https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcdn.jsdelivr.net%2Fgh%2Fopenlayers%2Fopenlayers.github.io%40master%2Fen%2Fv6.1.1%2Fcss%2Fol.css&data=02%7C01%7Crair19%40uni.coventry.ac.uk%7Cab61f4c4919e4ee5676408d7a64c90da%7C4b18ab9a37654abeac7c0e0d398afd4f%7C0%7C0%7C637160720081495136&sdata=ayQGq6iUJRn4qiEq1qxedI%2FLY7kfKrA1ty4%2FcHp4scg%3D&reserved=0" type="text/css"> | |
<style> | |
.map { | |
height: 400px; | |
width: 100%; | |
} | |
</style> | |
<script src="https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcdn.jsdelivr.net%2Fgh%2Fopenlayers%2Fopenlayers.github.io%40master%2Fen%2Fv6.1.1%2Fbuild%2Fol.js&data=02%7C01%7Crair19%40uni.coventry.ac.uk%7Cab61f4c4919e4ee5676408d7a64c90da%7C4b18ab9a37654abeac7c0e0d398afd4f%7C0%7C0%7C637160720081495136&sdata=yFIDZuJ6cQum8EzRv64SikPEGhVcrQxZSbvaZPXogY8%3D&reserved=0"></script> | |
<script> | |
function initialize_map(longArray,latArray,dateArray,tidArray) { | |
var map = new ol.Map({ | |
target: 'map', | |
layers: [ | |
new ol.layer.Tile({ | |
source: new ol.source.OSM() | |
}) | |
]; | |
view: new ol.View({ | |
center: ol.proj.fromLonLat([-1.5197, 52.4068]), | |
zoom: 12 | |
}) | |
}); | |
var tidColor = colorDictionary(tidArray); | |
add_map_point(map,tidColor,longArray,latArray,dateArray,tidArray); | |
} | |
function add_map_point(map,tidColor,longArray,latArray,dateArray,tidArray) { | |
for (i=0; i<latArray.length; i++) | |
{ | |
if ((tidArray[i] == tidArray[i+1] || tidArray[i]==tidArray[i-1]) && (dateArray[i] == dateArray[i+1] || dateArray[i]==dateArray[i-1])) | |
{ | |
var marker1 = new ol.layer.Vector({ | |
title: tidArray[i], | |
source: new ol.source.Vector({ | |
features: [ | |
new ol.Feature({ | |
geometry: new ol.geom.Point(ol.proj.fromLonLat([longArray[i],latArray[i]])) | |
}) | |
] | |
}), | |
style: new ol.style.Style({ | |
image: new ol.style.Icon(/** @type {olx.style.IconOptions} */({ | |
color: tidColor[tidArray[i]], | |
crossOrigin: 'anonymous', | |
//anchor: [0.5, 0.5], | |
anchorXUnits: "fraction", | |
anchorYUnits: "fraction", | |
scale : 0.03, | |
//src: "https://image.flaticon.com/icons/svg/446/446075.svg", | |
src: "https://upload.wikimedia.org/wikipedia/commons/a/a0/Circle_-_black_simple.svg", | |
//src: "https://upload.wikimedia.org/wikipedia/commons/e/ec/RedDot.svg" //get an image for our red dot | |
//src: 'https://upload.wikimedia.org/wikipedia/commons/thumb/9/93/Map_marker_font_awesome.svg/200px-Map_marker_font_awesome.svg.png', | |
//src:"https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fimage.flaticon.com%2Ficons%2Fsvg%2F1397%2F1397898.svg&data=02%7C01%7Crair19%40uni.coventry.ac.uk%7Cab61f4c4919e4ee5676408d7a64c90da%7C4b18ab9a37654abeac7c0e0d398afd4f%7C0%7C0%7C637160720081495136&sdata=ILOTpuqrhe94M%2BMNexenwuxycoE73Ygy%2FkroSxzj7JM%3D&reserved=0", | |
//src: "https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fcommons%2Fe%2Fec%2FRedDot.svg&data=02%7C01%7Crair19%40uni.coventry.ac.uk%7Cab61f4c4919e4ee5676408d7a64c90da%7C4b18ab9a37654abeac7c0e0d398afd4f%7C0%7C0%7C637160720081495136&sdata=D0cQ9nzdQBcHctQZxzScWs%2FtlPHq3Byvcgmo%2BkUgEEA%3D&reserved=0", | |
})) | |
}) | |
}); | |
map.addLayer(marker1); | |
} else | |
{ | |
continue; | |
} | |
} | |
map.on("singleclick", function (evt) { | |
this.forEachFeatureAtPixel(evt.pixel, function (feature, layer) { | |
alert("tid: " + layer.get("title")); | |
evt.preventDefault(); | |
}); | |
}); | |
add_lines(map,tidColor,longArray,latArray,dateArray,tidArray) | |
} | |
function add_lines(map,tidColor,longArray,latArray,dateArray,tidArray){ | |
for (i=0; i<latArray.length-1; i++) | |
{ | |
var loc1 = ol.proj.fromLonLat([longArray[i],latArray[i]]); | |
var loc2 = ol.proj.fromLonLat([longArray[i+1],latArray[i+1]]); | |
var lineStyle = [ | |
new ol.style.Style({ | |
stroke: new ol.style.Stroke({ | |
color: tidColor[tidArray[i]], | |
width: 2 | |
}) | |
}) | |
]; | |
if (tidArray[i]==tidArray[i+1] && dateArray[i]==dateArray[i+1]) | |
{ | |
var myLine = new ol.layer.Vector({ | |
title: tidArray[i], | |
source: new ol.source.Vector({ | |
features: [new ol.Feature({ | |
geometry: new ol.geom.LineString([loc1, loc2]), | |
name: 'Line', | |
})] | |
}) | |
}); | |
} else { | |
continue; | |
} | |
map.on("singleclick", function (evt) { | |
this.forEachFeatureAtPixel(evt.pixel, function (feature, layer) { | |
alert("tid: " + layer.get("title")); | |
evt.preventDefault(); | |
}); | |
}); | |
myLine.setStyle(lineStyle); | |
map.addLayer(myLine); | |
} | |
} | |
function colorDictionary(tidArray) | |
{ | |
var tidColor = {}; | |
var uniqueTid = []; | |
for (i=0; i<tidArray.length; i++) | |
{ | |
if (tidArray[i] !== tidArray[i-1] && tidArray[i]==tidArray[i+1]) | |
{ | |
uniqueTid.push(tidArray[i]); | |
} | |
} | |
for (i=0; i<uniqueTid.length; i++) | |
{ | |
tidColor[uniqueTid[i]] = colorArray[i]; | |
} | |
return tidColor; | |
} | |
</script> | |
</head> | |
<body onload="initialize_map(arrayColumn({{locations}}, 0),arrayColumn({{locations}}, 1),arrayColumn({{locations}}, 2),arrayColumn({{locations}}, 4));"> | |
<h2>My Map</h2> | |
<div id="map" class="map"></div> | |
<table width="100%" border="0"> | |
<tbody> | |
<tr style="font-size:40px;"> | |
<td style="font-family:Arial; text-align:center">Location Tracker</td> | |
</tr> | |
</tbody> | |
</table> | |
<table width="100%" border="0"> | |
<tbody> | |
<tr style="font-size:16px; font-family:Arial; text-align:center"> | |
<th>TID</th> | |
<th>Longitude</th> | |
<th>Latitude</th> | |
<th>Date</th> | |
<th>Time</th> | |
</tr> | |
{% for item in locations %} | |
<tr> | |
<td style="font-size:18px;font-family:Arial; text-align:center"; width="5%">{{ item[4] }}</td> | |
<td style="font-size:18px;font-family:Arial; text-align:center"; width="25%">{{ item[0] }}</td> | |
<td style="font-size:18px;font-family:Arial; text-align:center"; width="25%">{{ item[1] }}</td> | |
<td style="font-size:18px;font-family:Arial; text-align:center"; width="15%">{{ item[2] }}</td> | |
<td style="font-size:18px;font-family:Arial; text-align:center"; width="20%">{{ item[3] }}</td> | |
</tr> | |
{% endfor %} | |
</tbody> | |
</table> | |
</body> | |
</html> |