PHD Project - Driver energy prediction
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

222 lines
17 KiB

<html>
<head>
<title>Google Map</title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<style>
#map {
height: 98%;
width: 98%;
margin: 0px;
padding: 0px
}
</style>
</head>
<body>
<div style="padding:10px">
<div id="map"></div>
</div>
<script type="text/javascript">
//const latLng = { lat: 48.783301, lng: 11.413787 };
//console.log("Delete all Markers");
// In the following example, markers appear when the user clicks on the map.
// Each marker is labeled with a single alphabetical character.
var marker_s;
var marker_d;
var coord_s;
var coord_d;
var diff;
var line;
var rotation = 0;
var map;
var icon;
function initMap() {
coord_s = {
lat: 48.783301,
lng: 11.413787
};
icon = {
path: "m 86.244606,487.66203 c -0.09081,5.4e-4 -0.284202,0.0186 -0.389407,0.0564 l -0.210693,0.0902 0.521091,2.1634 -7.513407,0.0165 c -0.146656,3.1e-4 -0.294228,-0.001 -0.442084,-0.002 -0.295695,-0.002 -0.593853,-0.006 -0.89359,-0.0124 -0.439003,-0.01 -0.883054,-0.0248 -1.328105,-0.0433 -0.02383,-0.001 -0.04763,-0.002 -0.07149,-0.004 -0.898886,-0.038 -1.806384,-0.0897 -2.71081,-0.14678 -1.2236,-0.0772 -2.439253,-0.16288 -3.61939,-0.23325 -0.874568,-0.052 -1.729632,-0.0952 -2.550922,-0.12034 -0.564015,-0.0165 -1.111509,-0.0274 -1.640418,-0.0245 -0.259806,0.001 -0.515771,0.006 -0.765667,0.0124 -0.249873,0.009 -0.504472,0.0215 -0.761877,0.0395 -0.128715,0.009 -0.257518,0.0186 -0.387523,0.0301 -0.389419,0.0342 -0.785294,0.0795 -1.179535,0.13171 -5.85e-4,6e-5 -0.0013,-6e-5 -0.0018,0 -0.263221,0.0349 -0.524844,0.0737 -0.786317,0.11476 -0.261496,0.0409 -0.522128,0.0843 -0.778791,0.12985 -0.256068,0.0457 -0.509907,0.0944 -0.758144,0.14306 -5.87e-4,1.2e-4 -0.0013,-1.1e-4 -0.0018,0 -0.1244,0.0244 -0.24499,0.0486 -0.366833,0.0735 -0.364888,0.0747 -0.718413,0.15152 -1.053478,0.22761 -5.86e-4,1.3e-4 -0.0013,-1.2e-4 -0.0018,0 -0.22373,0.0508 -0.438682,0.1008 -0.645271,0.1505 -0.413192,0.0993 -0.789506,0.19468 -1.115543,0.28031 -0.489031,0.1284 -0.865778,0.23639 -1.089237,0.30098 -0.148906,0.0431 -0.229509,0.0678 -0.229509,0.0678 l -0.82394,0.22575 c -0.05432,0.0145 -0.107045,0.0417 -0.15803,0.0791 -0.01734,0.0124 -0.03386,0.0262 -0.05078,0.0413 -0.06618,0.059 -0.12948,0.13667 -0.190009,0.23141 -2.76e-4,4.1e-4 2.77e-4,10e-4 0,0.002 -0.03012,0.0472 -0.06155,0.0987 -0.0903,0.15421 -2.52e-4,4.7e-4 2.54e-4,0.001 0,0.002 -0.02876,0.0555 -0.05724,0.11524 -0.08464,0.17877 -2.22e-4,5.4e-4 2.24e-4,0.001 0,0.002 -0.220748,0.51226 -0.398514,1.27206 -0.538021,2.18033 -9e-5,5.4e-4 9.1e-5,10e-4 0,0.002 -0.0023,0.0145 -0.0035,0.0292 -0.0056,0.0431 -0.03037,0.20046 -0.05972,0.40925 -0.08653,0.62271 -0.0018,0.0145 -0.0039,0.0285 -0.0056,0.0431 -0.0302,0.2434 -0.057,0.49379 -0.08278,0.75062 -5.9e-5,5.3e-4 6.1e-5,10e-4 0,0.002 -0.0128,0.1282 -0.02583,0.25855 -0.03763,0.38943 -5.3e-5,5.3e-4 5.6e-5,10e-4 0,0.002 -0.01178,0.13088 -0.02312,0.26181 -0.03385,0.39506 -5e-5,5.2e-4 4.9e-5,10e-4 0,0.002 -0.02153,0.26713 -0.04082,0.53852 -0.05833,0.81268 -4e-5,5.3e-4 4.2e-5,0.001 0,0.002 -0.05252,0.82376 -0.08786,1.67288 -0.107226,2.50198 -1.5e-5,5.4e-4 1.4e-5,0.001 0,0.002 -0.01301,0.5532 -0.01879,1.0964 -0.01879,1.61977 0,0.0582 0.0017,0.11803 0.0018,0.17692 -2.23e-4,0.0587 -0.0018,0.11852 -0.0018,0.17691 0,0.52333 0.0059,1.06654 0.01879,1.61971 1.7e-5,5.5e-4 -1.5e-5,0.001 0,0.002 0.01941,0.82919 0.05471,1.67824 0.107226,2.502 3.9e-5,5.1e-4 -4e-5,10e-4 0,0.002 0.01755,0.27415 0.03678,0.54553 0.05833,0.81268 4.9e-5,5.3e-4 -5e-5,10e-4 0,0.002 0.01069,0.13315 0.02206,0.26415 0.03385,0.39504 5.6e-5,5.3e-4 -5.5e-5,10e-4 0,0.002 0.01178,0.13089 0.02477,0.26127 0.03761,0.38941 6.2e-5,5.5e-4 -6e-5,10e-4 0,0.002 0.02578,0.25683 0.05258,0.50723 0.08278,0.75062 0.0018,0.0144 0.0038,0.0287 0.0056,0.0431 0.02681,0.21343 0.05615,0.42213 0.08653,0.62271 0.0021,0.0145 0.0035,0.0291 0.0056,0.0431 9.1e-5,5.4e-4 -9e-5,10e-4 0,0.002 0.139513,0.90821 0.317272,1.66807 0.538021,2.18035 2.23e-4,5.3e-4 -2.22e-4,0.001 0,0.002 0.0274,0.0636 0.05591,0.12304 0.08464,0.17877 2.54e-4,4.9e-4 -2.53e-4,0.001 0,0.002 0.02876,0.0555 0.06017,0.10699 0.0903,0.15421 2.77e-4,4.3e-4 -2.76e-4,10e-4 0,0.002 0.06051,0.0947 0.123802,0.17238 0.190008,0.23139 0.01693,0.0145 0.03347,0.0287 0.05078,0.0413 0.05099,0.0374 0.103693,0.064 0.15803,0.0791 l 0.82394,0.22574 c 0,0 0.0806,0.0245 0.229509,0.0678 0.223404,0.0646 0.600182,0.17259 1.089237,0.30099 0.326019,0.0857 0.702339,0.18105 1.115544,0.28031 0.206565,0.0495 0.421522,0.0997 0.64527,0.15049 6.4e-4,10e-5 0.0013,-1.2e-4 0.0018,0 0.335071,0.0761 0.688552,0.15277 1.053478,0.22762 0.12184,0.025 0.242439,0.0489 0.366833,0.0732 5.87e-4,1.3e-4 0.0013,-1.3e-4 0.0018,0 0.248212,0.0487 0.50205,0.0974 0.758141,0.14285 0.256689,0.0457 0.51732,0.0888 0.778793,0.12986 0.261498,0.0411 0.523115,0.0799 0.786317,0.11476 6.4e-4,4e-5 0.0013,-9e-5 0.0018,0 0.394217,0.0522 0.790109,0.0974 1.179534,0.13171 0.130017,0.0124 0.258819,0.021 0.387524,0.0301 0.257411,0.0186 0.512009,0.0319 0.761877,0.0395 0.249873,0.009 0.505837,0.0124 0.765667,0.0124 0.5289,0.004 1.076414,-0.006 1.640415,-0.0244 0.821233,-0.0254 1.676356,-0.0684 2.550925,-0.12034 1.180137,-0.0702 2.395789,-0.15607 3.61939,-0.23328 0.904425,-0.057 1.811864,-0.10881 2.71081,-0.14679 0.02385,-10e-4 0.04765,-0.002 0.07149,-0.004 0.445073,-0.0186 0.889137,-0.0333 1.328105,-0.0434 0.299712,-0.006 0.597868,-0.01 0.89359,-0.0124 0.147852,-10e-4 0.295412,-0.002 0.442083,-0.002 l 7.513408,0.0165 -0.521095,2.16342 0.210697,0.0902 c 0.105199,0.038 0.298589,0.056 0.389407,0.0563 0.05109,3.2e-4 0.10566,-0.004 0.161787,-0.0145 0.01879,-0.004 0.03755,-0.009 0.05644,-0.0124 0.01837,-0.004 0.03807,-0.01 0.05644,-0.0145 0.03781,-0.0124 0.07605,-0.0254 0.112886,-0.0413 0.109668,-0.0477 0.212756,-0.11621 0.287826,-0.19942 5.33e-4,-5.4e-4 0.0011,-10e-4 0.0021,-0.002 0.0376,-0.0421 0.06695,-0.0873 0.08842,-0.13728 l 0.731779,-1.88495 6.618251,0.0145 c 0.04497,0.0225 0.08885,0.0448 0.133567,0.0658 0.179334,0.0843 0.355831,0.15628 0.532372,0.21821 0.08803,0.031 0.17564,0.0586 0.263368,0.0846 0.30701,0.0908 0.613302,0.15359 0.923689,0.1957 0.177353,0.0242 0.356734,0.0416 0.538021,0.0545 0.09065,0.006 0.182637,0.01 0.274652,0.0144 0.184021,0.009 0.369537,0.0124 0.560593,0.0145 0.382113,0.004 0.781322,0 1.203978,0 0.626667,0 1.223367,-0.0319 1.792787,-0.0941 0.22776,-0.0248 0.45095,-0.054 0.66971,-0.0884 0.4375,-0.0687 0.85651,-0.15772 1.25851,-0.26335 0.1005,-0.0265 0.20081,-0.054 0.29911,-0.0828 0.29491,-0.0861 0.57868,-0.18208 0.85404,-0.28783 0.0918,-0.0353 0.18313,-0.0698 0.27278,-0.1071 0.17929,-0.0747 0.35408,-0.15401 0.52484,-0.23703 0.0854,-0.0415 0.17069,-0.0843 0.25396,-0.12799 0.16654,-0.0871 0.3291,-0.1794 0.48724,-0.27465 0.0791,-0.0477 0.15627,-0.0973 0.23327,-0.14678 0.38492,-0.24802 0.74423,-0.51924 1.07791,-0.81456 0.2666,-0.23593 0.5178,-0.48639 0.75249,-0.75061 3e-4,-3.5e-4 -3e-4,-0.001 0,-0.002 0.0584,-0.0658 0.1166,-0.13191 0.17306,-0.19942 3e-4,-3.5e-4 -3e-4,-0.001 0,-0.002 0.0565,-0.0675 0.11292,-0.13583 0.16742,-0.205 3e-4,-3.4e-4 -3e-4,-10e-4 0,-0.002 0.16408,-0.20817 0.31985,-0.42252 0.46654,-0.64527 3e-4,-4.1e-4 -3e-4,-10e-4 0,-0.002 0.0487,-0.074 0.0981,-0.14843 0.14486,-0.22387 2.9e-4,-4.9e-4 -3e-4,-10e-4 0,-0.002 0.14089,-0.22745 0.27491,-0.46068 0.39881,-0.70168 2.4e-4,-4.9e-4 -2.4e-4,-10e-4 0,-0.002 0.0411,-0.0801 0.0811,-0.16122 0.12039,-0.24267 2.4e-4,-4.7e-4 -2.5e-4,-10e-4 0,-0.002 0.0392,-0.0815 0.0792,-0.1635 0.11663,-0.24645 2.4e-4,-5.3e-4 -2.4e-4,-10e-4 0,-0.002 0.0751,-0.16639 0.14676,-0.3342 0.21446,-0.50604 2.4e-4,-5.4e-4 -2.4e-4,-0.001 0,-0.002 0.0337,-0.0857 0.0659,-0.17258 0.0978,-0.25962 1.8e-4,-5.4e-4 -1.8e-4,-0.001 0,-0.002 0.0319,-0.087 0.064,-0.17506 0.094,-0.26338 0.0301,-0.0884 0.0601,-0.17754 0.0884,-0.26714 1.8e-4,-5.3e-4 -1.9e-4,-10e-4 0,-0.002 0.0283,-0.0896 0.0562,-0.18002 0.0828,-0.2709 1.7e-4,-5.3e-4 -1.8e-4,-10e-4 0,-0.002 0.0265,-0.0908 0.0524,-0.18249 0.0771,-0.27467 1.8e-4,-5.4e-4 -1.7e-4,-0.001 0,-0.002 0.0745,-0.27752 0.14257,-0.56022 0.20128,-0.84844 v -0.002 c 0.0194,-0.0958 0.0368,-0.19281 0.0546,-0.28972 v -0.002 c 0.1249,-0.68132 0.20842,-1.38831 0.2502,-2.12015 3e-5,-5.1e-4 -4e-5,-10e-4 0,-0.002 0.006,-0.10407 0.0107,-0.20922 0.0151,-0.31415 2e-5,-5.4e-4 -3e-5,-0.001 0,-0.002 0.009,-0.2105 0.0149,-0.42182 0.0169,-0.63582 0,-5.3e-4 -10e-6,-10e-4 0,-0.002 0.001,-0.10735 5.3e-4,-0.2154 0,-0.32358 0,-0.0381 -10e-4,-0.0766 -0.002,-0.11475 5.3e-4,-0.0383 0.002,-0.0766 0.002,-0.11476 5.3e-4,-0.1082 0.001,-0.21623 0,-0.32357 -10e-6,-5.3e-4 0,-10e-4 0,-0.002 -0.002,-0.21402 -0.009,-0.42534 -0.0169,-0.63582 -3e-5,-5.4e-4 2e-5,-0.001 0,-0.002 -0.004,-0.10492 -0.009,-0.21016 -0.0151,-0.31418 -4e-5,-5.2e-4 3e-5,-10e-4 0,-0.002 -0.0418,-0.73183 -0.12531,-1.43874 -0.2502,-2.12015 v -0.002 c -0.0177,-0.0968 -0.0351,-0.19405 -0.0546,-0.28971 v -0.002 c -0.0587,-0.28822 -0.12675,-0.57092 -0.20128,-0.84844 -1.7e-4,-5.2e-4 1.8e-4,-10e-4 0,-0.002 -0.0248,-0.0921 -0.0506,-0.18374 -0.0771,-0.27465 -1.8e-4,-5.5e-4 1.7e-4,-10e-4 0,-0.002 -0.0265,-0.0908 -0.0545,-0.18126 -0.0828,-0.2709 -1.9e-4,-5.3e-4 1.8e-4,-10e-4 0,-0.002 -0.0283,-0.0896 -0.0583,-0.17878 -0.0884,-0.26714 -0.0301,-0.0884 -0.0622,-0.17629 -0.094,-0.26335 -1.8e-4,-5.4e-4 1.8e-4,-10e-4 0,-0.002 -0.0319,-0.087 -0.0641,-0.17403 -0.0978,-0.2596 -2.4e-4,-5.4e-4 2.4e-4,-0.001 0,-0.002 -0.0677,-0.17176 -0.13943,-0.33976 -0.21446,-0.50604 -2.4e-4,-4.8e-4 2.4e-4,-0.001 0,-0.002 -0.0374,-0.0828 -0.0774,-0.16495 -0.11663,-0.24645 -2.5e-4,-4.8e-4 2.4e-4,-0.001 0,-0.002 -0.0392,-0.0815 -0.0793,-0.16268 -0.12039,-0.24268 -2.4e-4,-5e-4 2.4e-4,-0.001 0,-0.002 -0.12391,-0.24101 -0.25792,-0.47425 -0.39881,-0.70166 -3e-4,-4.3e-4 2.9e-4,-10e-4 0,-0.002 -0.0468,-0.0755 -0.0962,-0.14988 -0.14486,-0.22388 -3e-4,-4.2e-4 3e-4,-10e-4 0,-0.002 -0.1467,-0.22274 -0.30246,-0.43708 -0.46654,-0.64527 -3e-4,-3.8e-4 3e-4,-10e-4 0,-0.002 -0.0545,-0.0692 -0.11098,-0.13749 -0.16742,-0.20499 -3e-4,-3.8e-4 3e-4,-0.001 0,-0.002 -0.0565,-0.0675 -0.11466,-0.13357 -0.17306,-0.19942 -3e-4,-3.5e-4 3e-4,-10e-4 0,-0.002 -0.23468,-0.26419 -0.48588,-0.51465 -0.75249,-0.75061 -0.33368,-0.29532 -0.693,-0.56654 -1.07791,-0.81455 -0.077,-0.0495 -0.15421,-0.0991 -0.23327,-0.14679 -0.15814,-0.0952 -0.3207,-0.18745 -0.48724,-0.27465 -0.0833,-0.0436 -0.16857,-0.0863 -0.25396,-0.12799 -0.17076,-0.0832 -0.34556,-0.16226 -0.52484,-0.237 -0.0897,-0.0374 -0.18099,-0.072 -0.27278,-0.10711 -0.27538,-0.10565 -0.55914,-0.2019 -0.85404,-0.28781 -0.0983,-0.0287 -0.19861,-0.0564 -0.29911,-0.0828 -0.40199,-0.10565 -0.82099,-0.19467 -1.25851,-0.26338 -0.21875,-0.0345 -0.44195,-0.0636 -0.66971,-0.0884 -0.5694,-0.0622 -1.16612,-0.0941 -1.792787,-0.0941 -0.42262,0 -0.821834,-0.004 -1.203978,0 -0.19106,0.002 -0.376566,0.006 -0.560593,0.0145 -0.09201,0.004 -0.184021,0.009 -0.274652,0.0145 -0.181296,0.0124 -0.360663,0.0306 -0.538021,0.0545 -0.31036,0.0421 -0.616679,0.10492 -0.923689,0.1957 -0.08771,0.0257 -0.17535,0.0537 -0.263368,0.0846 -0.176548,0.0619 -0.353038,0.13398 -0.532372,0.21823 -0.0447,0.021 -0.0886,0.0434 -0.133567,0.0658 l -6.618251,0.0145 -0.731779,-1.88494 c -0.02145,-0.0499 -0.05082,-0.0953 -0.08842,-0.13728 -5.32e-4,-5.4e-4 -0.0011,-0.001 -0.0021,-0.002 -0.07506,-0.0832 -0.178179,-0.15153 -0.287826,-0.19942 -0.03678,-0.0165 -0.07505,-0.0297 -0.112886,-0.0413 -0.01837,-0.006 -0.03807,-0.0109 -0.05644,-0.0145 -0.01879,-0.004 -0.03775,-0.01 -0.05644,-0.0124 -0.05613,-0.01 -0.1107,-0.0145 -0.161787,-0.0145 z",
fillColor: '#800000',
fillOpacity: 0.8,
strokeWeight: 0.84278,
//origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(75, 502),
scale: .75,
rotation: (rotation - 90)
}
diff = 0
map = new google.maps.Map(document.getElementById("map"), {
zoom: 12,
center: coord_s,
});
// This event listener calls addMarker() when the map is clicked.
google.maps.event.addListener(map, "click", (event) => {
addMarker(event.latLng, map);
});
// Add a marker at the center of the map.
addMarker(coord_s, map);
// Add traffic layer
const trafficLayer = new google.maps.TrafficLayer();
trafficLayer.setMap(map);
// This event listener calls when the Markers are moved
google.maps.event.addListener(marker_s, 'dragend', function(event) {
if (diff == 2) {
coord_s = marker_s.getPosition();
line.setMap(null);
line = new google.maps.Polyline({
path: [marker_s.getPosition(), marker_d.getPosition()],
geodesic: true,
strokeColor: '#FF0000',
strokeOpacity: 1.0,
strokeWeight: 2
});
line.setMap(map);
} else {
coord_s = marker_s.getPosition();
}
returnS();
//console.log("S Position moved" + coord_s)
//console.log("diff = " + diff)
});
google.maps.event.addListener(marker_d, 'dragend', function(event) {
coord_d = marker_d.getPosition();
returnD();
line.setMap(null);
line = new google.maps.Polyline({
path: [marker_s.getPosition(), marker_d.getPosition()],
geodesic: true,
strokeColor: '#FF0000',
strokeOpacity: 1.0,
strokeWeight: 2
});
line.setMap(map);
//console.log("D Position moved" + coord_d)
//console.log("diff = "+ diff)
});
}
// Adds a marker to the map.
function addMarker(location, map) {
// Add the marker at the clicked location, and add the next-available label
// from the array of alphabetical characters.
if (diff == 0) { // Add start
marker_s = new google.maps.Marker({
position: location,
map: map,
draggable: true,
icon: icon
});
coord_s = location;
returnS();
marker_d = new google.maps.Marker({
position: location,
label: "D",
map: map,
draggable: true,
});
marker_d.setMap(null);
diff = 1;
//console.log("Init: S New Position " + coord_s)
//console.log("diff = "+ diff)
} else if (diff == 1) { // Add destination
coord_d = location;
returnD();
marker_d.setPosition(location);
marker_d.setMap(map);
line = new google.maps.Polyline({
path: [coord_s, coord_d],
geodesic: true,
strokeColor: '#FF0000',
strokeOpacity: 1.0,
strokeWeight: 2
});
line.setMap(map);
diff = 2;
//console.log("D New Position " + coord_d)
//console.log("diff = "+ diff)
} else { // Add new start
coord_s = location;
returnS();
coord_d = null;
returnD();
marker_d.setMap(null);
line.setMap(null);
marker_s.setPosition(location);
diff = 1;
//console.log("S New Position " + coord_s)
//console.log("diff = "+ diff)
}
}
function returnS() {
try {
var out = {
lat: coord_s.lat(),
lng: coord_s.lng()
};
} catch {
var out = {
lat: coord_s.lat,
lng: coord_s.lng
};
}
return out;
}
function returnD() {
try {
var out = {
lat: coord_d.lat(),
lng: coord_d.lng()
};
} catch {
var out = {
lat: null,
lng: null
};
}
return out;
}
function updateHeading() {
icon.rotation = (rotation - 90);
marker_s.setMap(null);
marker_s = new google.maps.Marker({
position: marker_s.getPosition(),
map: map,
draggable: true,
icon: icon,
});
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyClu2yvJQjVAQIqs1v6eSEXSgwUNVeDLZM&callback=initMap" async defer></script>
</body>
</html>