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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
| <!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="style.css">
<script src='//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.6.0/underscore.js'></script>
<script src='//maps.google.com/maps/api/js?v=3.12&sensor=false&client=&key=&libraries=geometry&language=&hl=®ion='></script>
<script src='//google-maps-utility-library-v3.googlecode.com/svn/tags/markerclustererplus/2.0.14/src/markerclusterer_packed.js'></script>
<script src='//cdnjs.cloudflare.com/ajax/libs/gmaps4rails/2.1.2/gmaps4rails.js'></script>
<script src="script.js" type="text/javascript"></script>
<script>function Init() {
var path = new google.maps.MVCArray();
var service = new google.maps.DirectionsService();
var poly, handler;
var myOptions = {
zoom: 14,
center: new google.maps.LatLng(48.9155868, 24.7022357),
draggableCursor: "crosshair"
}
function addMapListner(){
poly = new google.maps.Polyline({ map: handler.getMap() });
google.maps.event.addListener(handler.getMap(), "click", function(evt) {
if (path.getLength() === 0) {
path.push(evt.latLng);
poly.setPath(path);
} else {
var n = service.route({
origin: path.getAt(path.getLength() - 1),
destination: evt.latLng,
travelMode: google.maps.DirectionsTravelMode.DRIVING
}, function(result, status) {
if (status == google.maps.DirectionsStatus.OK) {
for (var i = 0, len = result.routes[0].overview_path.length; i < len; i++) {
path.push(result.routes[0].overview_path[i]);
var cordinats =(result.routes[0]['bounds']);
var cordinats =(result.routes[0]['bounds']);
var nameStreet = result.routes[0]['summary'];
var steps = result.routes[0]['legs']['distance'];
var big_info = result.routes[0]['legs'][0]['end_address'];
var info2 = result.routes[0]['legs'][0]['start_address'];
}
var infowindow = new google.maps.InfoWindow();
var contentMazepi = '<div id="content1">'+
"<div > "+nameStreet+" </div>"+
"<div > "+cordinats+" </div>"+
"<div > "+big_info+" </div>"+
"<div > "+info2+" </div>"+
"<table>" +
"<tr><td>Name street:</td> <td><input type='text' id='name' size='30' value='"+nameStreet+"'/> </td> </tr>" +
"<tr><td>Adres:</td> <td><input type='text' id='address' size='30' value='"+info+"'/></td> </tr>" +
"<tr><td>cordinats</td> <td><input type='text' id='address' size='60' value='"+cordinats+"'/></td> </tr>" +
"<tr><td>color stret</td> <td><select id='type'>" +
"<option value='blue' SELECTED>blue</option>" +
"<option value='green' SELECTED>green</option>" +
"<option value='black'>black</option>" +
"</select> </td></tr>" +
"<tr><td></td><td><input type='button' value='Save' onclick='saveData()'/></td></tr>"
'</div>';
infowindow.setContent(contentMazepi);
infowindow.position = (48.994354402426644,24.70584869384765);
infowindow.open(handler.getMap());
}
});
}
});
}
function createStreet(){
var start_point = [48.9180227, 24.7198334];
var end_point = [48.9057838,24.7147594];
var directionsService = new google.maps.DirectionsService();
var directionsDisplay = new google.maps.DirectionsRenderer({ polylineOptions: {
strokeColor: "#8b0000",
strokeWeight: 4,
strokeOpacity: 0.6} });
// polylineOptions: {strokeWeight: 6,strokeOpacity: 0.6, strokeColor: "#8b0013"}
directionsDisplay.setMap(handler.getMap());
directionsDisplay.setOptions({suppressMarkers:true});
var request = {
origin: new google.maps.LatLng(start_point[0], start_point[1]),
destination: new google.maps.LatLng(end_point[0], end_point[1]),
travelMode: google.maps.TravelMode.DRIVING
};
directionsService.route(request, function(response, status) {
if (status === google.maps.DirectionsStatus.OK) {
var b= directionsDisplay.setDirections(response);
var infowindow = new google.maps.InfoWindow();
}
});
google.maps.event.addListener(directionsService, "click", function (e)
{ infowindow.setPosition(e.latLng);
alert("tafddasfdasfdasfasdf");
infowindow.setContent("tafddasfdasfdasfasdf");
infowindow.opet(map);
});//you accidently reuse the last txt here infowindow.open(map); });
}
handler = Gmaps.build('Google'); //create maps
handler.buildMap({ provider: myOptions, internal: {id: 'map_canvas'}}, function(){
addMapListner();
createStreet(); //create routs
});
}
google.maps.event.addDomListener(window, 'load', Init);
</script>
</head>
<style>
html, body { height: 100%;
margin: 8px;
padding: 0px;
/*background-color: black;*/
}
#map_canvas {width: 1200px; height: 1000px; border: 3px solid blue;}
#content1{
background-color: hsl(162, 54%, 54%);
opacity: 0.7;
text-align: center;
font-size: 13px;
}
</style>
<body>
<div >
<div id="warnings_panel" style="width:100%;height:10%;text-align:center"></div>
<div id="panel"></div>
<div id="map_canvas">
</div>
</body>
</html> |