-
Notifications
You must be signed in to change notification settings - Fork 1
/
mapa.html
215 lines (170 loc) · 6.03 KB
/
mapa.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
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps JavaScript API Example</title>
<style type="text/css">
html
{
height:100%;
}
body
{
height:100%;
margin:0px;
padding:0px;
border-left:0px;
border-right:0px;
overflow:hidden;
}
</style>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script type="text/javascript">
//<![CDATA[
var map;
var point;
var wayPoint;
var trak;
var mapa;
var mapaI;
var mapaF;
var markerStart,markerEnd,markerPhoto;
//var greenIcon=new GIcon(G_DEFAULT_ICON,"http://www.google.com/intl/en_us/mapfiles/ms/micons/green-dot.png");
//var redIcon=new GIcon(G_DEFAULT_ICON,"http://www.google.com/intl/en_us/mapfiles/ms/micons/red-dot.png");
var blueIcon="http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png";
var photoIcon="http://maps.google.com/mapfiles/ms/micons/camera.png";
var startIcon="http://www.google.com/intl/en_us/mapfiles/dd-start.png";
var endIcon="http://www.google.com/intl/en_us/mapfiles/dd-end.png";
//http://google-maps-icons.googlecode.com/files
var photoIcon="http://paseos.laullon.com/wp-content/plugins/mapas/img/photo.png";
var pointIcon="http://paseos.laullon.com/wp-content/plugins/mapas/img/node.gif"
var track;
var fotos=new google.maps.MVCArray();
function load() {
var latlng = new google.maps.LatLng(32.713273,-117.175686);
var myOptions = {
zoom: 8,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map"), myOptions);
track = new google.maps.Polyline({
strokeColor: "#FF0000",
strokeOpacity: 1.0,
strokeWeight: 2
});
track.setMap(map);
track.setMap(map);
markerStart=new google.maps.Marker({map: map, icon: startIcon});
markerEnd=new google.maps.Marker({map: map, icon: endIcon});
markerPhoto=new google.maps.Marker({map: map, icon: photoIcon});
}
if (!google.maps.Polyline.prototype.getBounds)
google.maps.Polyline.prototype.getBounds = function() {
var bounds = new google.maps.LatLngBounds();
this.getPath().forEach( function(latlng) { bounds.extend(latlng); } );
return bounds;
}
function setTrak(points) {
try{
var path = [];
alert(points.length);
for(i=0;i<points.length;i+=2){
var point = new google.maps.LatLng(points[i],points[i+1]);
path.push(point);
}
track.setPath(path);
var pointS = new google.maps.LatLng(points[0],points[1]);
var pointE = new google.maps.LatLng(points[points.length-2],points[points.length-1]);
markerStart.setPosition(pointS);
markerEnd.setPosition(pointE);
map.fitBounds(track.getBounds());
}catch(err){
alert("ERROR: "+err.name + ": " + err.message);
}
}
function movePhotoIcon(lat,long){
var p=new google.maps.LatLng(lat,long);
markerPhoto.setPosition(p);
map.panTo(p);
}
function showAllPhotos(){
var bounds = new google.maps.LatLngBounds();
fotos.forEach( function(marker) { bounds.extend(marker.getPosition()); } );
map.fitBounds(bounds);
}
function clearPhotos(){
while(fotos.length){
var marker=fotos.pop();
marker.setMap(null);
}
}
function addPhoto(name,lat,long){
var p=new google.maps.LatLng(lat, long);
var marker=addMarker(name,p,pointIcon);
//fotos.push(marker);
google.maps.event.addListener(marker, 'click', function() { window.appController.selectPhotoById_(name); });
}
function addMarker(title,latLng,icon){
var marker = new google.maps.Marker({
position: latLng,
title: title,
map: map,
icon: icon
});
return marker;
}
function setPoint(lat,long) {
if(point!=null) map.removeOverlay(point);
point=center(lat,long);
}
function setWayPoint(lat,long) {
if(wayPoint!=null) map.removeOverlay(wayPoint);
wayPoint=center(lat,long);
}
function center(lat,long){
var p=new google.maps.LatLng(lat, long);
map.panTo(p, 10);
var res=new GMarker(p);
map.addOverlay(res);
res.setImage(blueIcon);
return res;
}
//function setTrak(trak){
/*if(trak!=null) map.removeOverlay(trak);
if(markerStart!=null) map.removeOverlay(markerStart);
if(markerEnd!=null) map.removeOverlay(markerEnd);
alert("-->setTrak");
trak = new Polyline.fromEncoded({color: "#0000ff", weight: 4, points: encodedPoints, levels: encodedLevels, zoomFactor: 10, numLevels: 4 });
map.addOverlay(trak);
var bounds=trak.getBounds();
var zoom=map.getBoundsZoomLevel(bounds);
map.setCenter(bounds.getCenter(), zoom);
markerStart = new GMarker(trak.getVertex(0));
markerEnd = new GMarker(trak.getVertex(trak.getVertexCount()-1));
map.addOverlay(markerStart);
map.addOverlay(markerEnd);
markerStart.setImage(startIcon);
markerEnd.setImage(endIcon);*/
//}
function setMap(encodedPoints,encodedLevels){
if(mapa!=null) map.removeOverlay(mapa);
if(mapaI!=null) map.removeOverlay(mapaI);
if(mapaF!=null) map.removeOverlay(mapaF);
mapa = new GPolyline.fromEncoded({color: "#ff0000", weight: 6, points: encodedPoints, levels: encodedLevels, zoomFactor: 10, numLevels: 4 });
mapaI = new GMarker(mapa.getVertex(0));
mapaF = new GMarker(mapa.getVertex(mapa.getVertexCount()-1));
map.addOverlay(mapa);
map.addOverlay(mapaI);
map.addOverlay(mapaF);
mapaI.setImage(startIcon);
mapaF.setImage(endIcon);
}
//]]>
</script>
</head>
<body onload="load()">
<div id="map" style="width: 100%; height: 100%"></div>
</body>
</html>