This repository has been archived by the owner on Dec 14, 2020. It is now read-only.
forked from jcschefer/Railroad_Map
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuilder.js
85 lines (66 loc) · 2.22 KB
/
builder.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
var drawLines = function(map, latLng){
console.log('about to load coordinate data');
var astarLat = gastarLat();
var astarLong = gastarLong();
var dijkstraLat = gdijkstraLat();
var dijkstraLong = gdijkstraLong();
var otherLat = gotherLat();
var otherLong = gotherLong();
console.log('builder.js received data!');
var lineWeight = 3;
for( i = 0; i < astarLat.length; i += 2)
{
var coordspathtoshow = [
{lat: parseFloat(astarLat[i]) , lng: parseFloat(astarLong[i])},
{lat: parseFloat(astarLat[i+1]), lng: parseFloat(astarLong[i+1])}
];
var polylinepathtoshow = new google.maps.Polyline( {
path : coordspathtoshow,
strokeColor : "#FF0000",
strokeOpacity : 1.0,
strokeWeight : lineWeight
});
polylinepathtoshow.setMap(map);
}
console.log('astar lines drawn!');
for( i = 0; i < dijkstraLat.length; i += 2)
{
var coordspathtoshow = [
{lat: parseFloat(dijkstraLat[i]) , lng: parseFloat(dijkstraLong[i])},
{lat: parseFloat(dijkstraLat[i+1]), lng: parseFloat(dijkstraLong[i+1])}
];
var polylinepathtoshow = new google.maps.Polyline( {
path : coordspathtoshow,
strokeColor : "#00FF00",
strokeOpacity : 1.0,
strokeWeight : lineWeight
});
polylinepathtoshow.setMap(map);
}
console.log('dijkstra lines drawn!');
for( i = 0; i < otherLat.length; i += 2)
{
var coordspathtoshow = [
{lat: parseFloat(otherLat[i]) , lng: parseFloat(otherLong[i])},
{lat: parseFloat(otherLat[i+1]), lng: parseFloat(otherLong[i+1])}
];
var polylinepathtoshow = new google.maps.Polyline( {
path : coordspathtoshow,
strokeColor : "#0000FF",
strokeOpacity : 1.0,
strokeWeight : lineWeight
});
polylinepathtoshow.setMap(map);
}
console.log('remaining lines drawn!');
}
function initialize() {
var latLng = new google.maps.LatLng(39.0,-96.0);
var map = new google.maps.Map(document.getElementById('mapCanvas'), {
zoom: 4,
center: latLng,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
google.maps.event.addListener(map, 'tilesloaded', drawLines(map, latLng));
}
google.maps.event.addDomListener(window, 'load', initialize);