-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmap.html
91 lines (82 loc) · 2.22 KB
/
map.html
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
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta charset="utf-8">
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map_canvas { height: 100% }
</style>
<title>Maps</title>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script type="text/javascript">
var map, myPaths = [], myObjects = [];
function initialize()
{
var center = new google.maps.LatLng(37.387635, -121.963427);
var mapOptions = {
zoom: 15,
center: center,
scrollWheelZoom: true,
doubleClickZoom: false
};
map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
}
function drawRoute(myCoordinates, myColor, nPath)
{
if (myCoordinates.length != 0)
{
myPaths[nPath] = new google.maps.Polyline({
path: myCoordinates,
strokeColor: myColor,
strokeOpacity: 4.0,
strokeWeight: 5,
map: map
});
google.maps.event.addListener(myPaths[nPath], 'click', function(evt)
{
Map.getCoordinates(evt.latLng.lat(), evt.latLng.lng());
}
);
}
}
function cleanupMap()
{
myPaths.forEach( function(item){if(item)item.setMap(null)});
myObjects.forEach(function(item){if(item)item.setMap(null)});
}
function removePath(nPath)
{
if(myPaths[nPath]) myPaths[nPath].setMap(null);
}
function removeObject(nObject)
{
if(myObjects[nObject]) myObjects[nObject].setMap(null);
}
function drawObject(objX, objY, rotate, color, nObject)
{
var arrow = {
path: google.maps.SymbolPath.FORWARD_CLOSED_ARROW,
fillColor: color,
fillOpacity: 0.8,
scale: 5,
rotation: rotate,
strokeColor: "white",
strokeWeight: 1
}
var objOptions = {
icon: arrow,
position: new google.maps.LatLng(objX, objY),
map: map
};
if(myObjects[nObject] != null)
myObjects[nObject].setMap(null);
myObjects[nObject] = new google.maps.Marker(objOptions);
}
</script>
</head>
<body onload="initialize()">
<div id="map_canvas" style="width: 100%; height: 100%;"></div>
</body>
</html>