summaryrefslogtreecommitdiff
path: root/modules/googlemap/wt_v3_street_view_setup.php
blob: 0641ab87b2bcbb7ae3576401e47673f870e7d635 (plain)
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
<?php
/**
 * Displays the streetview map setup page
 *
 * webtrees: Web based Family History software
 * Copyright (C) 2011 webtrees development team.
 *
 * Derived from PhpGedView
 * Copyright (C) 2002 to 2010  PGV Development Team. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * @package webtrees
 * @subpackage Googlemaps v3
 * @version $Id$
 *
 * @author Brian Holland (windmillway)
 */
 ?>

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>Google Maps JavaScript API V3: Street View Layer</title>
    <script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
    <script type="text/javascript">
    

    
	var qsParm = new Array();
	function qs() {
		var query = window.location.search.substring(1);
		var parms = query.split('&');
		for (var i=0; i<parms.length; i++) {
			var pos = parms[i].indexOf('=');
			if (pos > 0) {
				var key = parms[i].substring(0,pos);
				var val = parms[i].substring(pos+1);
				qsParm[key] = val;
			}
		}
	} 	
	qsParm['x'] = null;
	qsParm['y'] = null;
	qs();
    
    var map;
    
	function roundNumber(num, dec) {
		var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
		return result;
	}
    
    function initialize() {
    	
		var x = qsParm['x'];
    	var y = qsParm['y'];
    	var b = parseFloat(qsParm['b']);
    	var p = parseFloat(qsParm['p']);
    	var m = parseFloat(qsParm['m']);
    
      	var sv_location = new google.maps.LatLng(y, x);
   	
		var mapOptions = {
			zoom: 14,
			center: sv_location,
			mapTypeId: google.maps.MapTypeId.ROADMAP,					// ROADMAP, SATELLITE, HYBRID, TERRAIN
			mapTypeControlOptions: {
				style: google.maps.MapTypeControlStyle.DROPDOWN_MENU 	// DEFAULT, DROPDOWN_MENU, HORIZONTAL_BAR
			},
			navigationControl: true,
      		navigationControlOptions: {
   				position: google.maps.ControlPosition.TOP_RIGHT,		// BOTTOM, BOTTOM_LEFT, LEFT, TOP, etc
   				style: google.maps.NavigationControlStyle.SMALL			// ANDROID, DEFAULT, SMALL, ZOOM_PAN
      		},
      		streetViewControl: true,									// Show Pegman or not
      		scrollwheel: false
      		
		};
      	map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);


    	// === Next, get the map's default panorama and set up some defaults. ======================
    	var bearing = b;
    	var pitch = p;
    	var svzoom = m;
    	
    	// --- First check if Browser supports html5 ---
    	var browserName=navigator.appName;
    	if (browserName=="Microsoft Internet Explorer") {
    	    var render_type = '';
    	} else {
    	   	var render_type = 'html5';
    	}

		// --- Create the panorama ---   	 	
      	var panoramaOptions = {
      		navigationControl: false,
      		navigationControlOptions: {
      			position: google.maps.ControlPosition.TOP_LEFT,			// BOTTOM, BOTTOM_LEFT, LEFT, TOP, etc
      			style: google.maps.NavigationControlStyle.ANDROID  		// ANDROID, DEFAULT, SMALL, ZOOM_PAN
      		},
      		linksControl: false,
      		addressControl: false,
      		addressControlOptions: {
      			style: {
      				// display: 'none',									// USE CSS notation here
      				// backgroundColor: 'red'
      			}
      		},
        	position: sv_location,
        	mode: render_type, 
       		pov: {
          		heading: 0,
          		pitch: 0,
          		zoom: 1
          		//heading: bearing,
          		//pitch: pitch,
          		//zoom: svzoom
        	}
      	};  
      	var panorama = new google.maps.StreetViewPanorama(document.getElementById("pano"),panoramaOptions);
      	
    	map.setStreetView(panorama);
    	
    	// Enable navigator contol and address control to be toggled with right mouse button -------
		var aLink = document.createElement('a');
		aLink.href = "javascript:void(0)"; onmousedown=function(e) {
 			if (parseInt(navigator.appVersion)>3) {
  				var clickType=1;
  				if (navigator.appName=="Netscape") {
  					clickType=e.which;
  				} else {
  					clickType=event.button;
  				}
  				if (clickType==1) {
  					self.status='Left button!';
  				}
  				if (clickType!=1) {
					if (panorama.get('addressControl') == false) {
						panorama.set('addressControl', true);
						panorama.set('linksControl', true);
					} else {
						panorama.set('addressControl', false);
						panorama.set('linksControl', false);
					}
  				}
 			}
 			return true;
			if (parseInt(navigator.appVersion)>3) {
 				document.onmousedown = mouseDown;
 			if (navigator.appName=="Netscape") 
  				document.captureEvents(Event.MOUSEDOWN);
			}
		};
		panorama.controls[google.maps.ControlPosition.TOP_RIGHT].push(aLink);
		// -----------------------------------------------------------------------------------------
		
		google.maps.event.addListener(panorama, 'pov_changed', function() {
			povLevel = panorama.getPov();
        	parent.document.getElementById('sv_bearText').value = roundNumber(povLevel.heading, 2)+"\u00B0";
        	parent.document.getElementById('sv_elevText').value = roundNumber(povLevel.pitch, 2)+"\u00B0";
        	parent.document.getElementById('sv_zoomText').value = roundNumber(povLevel.zoom, 2);
		});	
		google.maps.event.addListener(panorama, 'position_changed', function() {
			pos = panorama.getPosition();		
        	parent.document.getElementById('sv_latiText').value = pos.lat()+"\u00B0";
        	parent.document.getElementById('sv_longText').value = pos.lng()+"\u00B0";
		});	
		
		//==========================================================================================
		//  CREATE THE MAP PANE STREETVIEW BLUE STREETS
		//======================================================================================
		//	First lets create the Traffic ImageMap
		//--------------------------------------------------------------------------------------
		var traffic = new google.maps.ImageMapType({
			getTileUrl: function(coord, zoom) {
				var X = coord.x % (1 << zoom);  // wrap
				return "http://mt3.google.com/mapstt?" +
					"zoom=" + zoom + "&x=" + X + "&y=" + coord.y + "&client=api";
			},
			tileSize: new google.maps.Size(256, 256),
			isPng: true
		});
		//======================================================================================
		//	Now add the ImageMapType overlay to the map
		//--------------------------------------------------------------------------------------
		map.overlayMapTypes.push(traffic);
		map.overlayMapTypes.push(null);
		//======================================================================================
		//	Now create the StreetView ImageMap
		//--------------------------------------------------------------------------------------
		// http://cbk0.google.com/cbk?output=overlay&zoom=12&x=2045&y=1361&cb_client=api
		var street = new google.maps.ImageMapType({
			getTileUrl: function(coord, zoom) {
				var X = coord.x % (1 << zoom);  // wrap
				return "http://cbk0.google.com/cbk?output=overlay&" +
					"zoom=" + zoom + "&x=" + X + "&y=" + coord.y + "&cb_client=api";
			},
			tileSize: new google.maps.Size(256, 256),
			isPng: true
		});
		//======================================================================================
		//  Add the Street view Image Map
		//--------------------------------------------------------------------------------------
		map.overlayMapTypes.setAt(1, street);
		//==========================================================================================
	
    }
    
	function resetview() {
		initialize();
	}
    
    // Instead of handling events directly in the tags attributes (ie. <body onload="...">),
    // listen to the events programmatically:
	google.maps.event.addDomListener(window, 'load', initialize);

    </script>
</head>
  
<body>  
  	<style>

  	#butt1, #butt2 {
  		width:90px;
  	}
  	#map_canvas {
    	width: 520px;
    	height: 250px;
    	margin: 0 auto;
    	margin-top: -10px;
		border:1px solid black;
  	}
  	#warning {
    	margin: 0 auto;
    	width: 520px;
    	height: 100px;
		border:0px solid black;
		text-align: left;
		font: 12px verdana; color:red;
		padding-left: 4px;
		margin-top:-5px;
		font-weight: normal;
  	}
  	#warning h5 {
  		font: 11px verdana; color:red;
  		font-weight: normal;
  	}
  	#pano {
    	margin: 0 auto;
  		margin-top:3px;
    	width: 520px;
    	height: 350px;
		border:1px solid black;
  	}
  	/*
  	#inputs {
    	margin: 0 auto;
  		background: #cccccc; 
  		margin-top: 0px; 
  		width: 510px; 
  		height: 15px;
  		padding-bottom: 10px; 
  		border:1px solid grey;
  	}
  	#inputs form {
  		margin-left: -8px;
  		font: 11px verdana; color:blue;
  	}
*/
  	#inputs form input {
  		background: #cccccc;
  	}
  	div {
  		text-align: center;
  	}
  	</style>
  	
  	<div id="toggle">
  		<form name="myForm" title="myForm">
  			<!-- <input id="butt1" name ="butt1" type="button" value="Map" onclick="toggleStreetView();"></input> -->
  				<input id="butt2" name ="butt2" type="button" value="Reset" onclick="resetview();"></input>
  		</form>
  	</div>

    <div id="map_canvas"> </div>
<!--    
	<div id="warning">
	<h5>
		<b>No Streetview coordinates are saved yet.</b><br />
		a. 	If no Streetview is displayed below, drag the "Pegman" to a "blue" Street on the map. <br />
		b. 	When the Streetview is displayed, adjust as necessary to enable the required view. <br />
			&nbsp;&nbsp;&nbsp; (Right mouse click to toggle Street view navigation arrows.) <br /> 
		c. 	When the required view is displayed, click the button "Save View".
	</h5>
	</div>
-->
	<div id="pano"></div>
	
<!--
    <div id="inputs">
	<?php
/*
		$placeid	= "";			// Placelocation place id
		$sv_lat		= "";			// StreetView Point of View Latitude
		$sv_lng 	= "";			// StreetView Point of View Longitude	
		$sv_bear 	= "0&#176;";	// StreetView Point of View Bearing/Heading/Yaw	(degrees from North)
		$sv_elev	= "0&#176;";	// StreetView Point of View Elevation/Pitch 	(+90 to -90 degrees (+=down, -=up)
		$sv_zoom	= "1";			// StreetView Point of View Zoom 				(0.00 to 5.00 )

 		$list_latlon = ("
			lati<input 		name='sv_latiText' id='sv_latiText' type='text' style='width:67px; border:none;' value='' 	/>
			long<input 		name='sv_longText' id='sv_longText' type='text' style='width:67px; border:none;' value='' 	/>
			bear<input 		name='sv_bearText' id='sv_bearText' type='text' style='width:50px; border:none;' value='".$sv_bear."' 	/>&nbsp;
			elev<input 		name='sv_elevText' id='sv_elevText' type='text' style='width:43px; border:none;' value='".$sv_elev."' 	/>
			zoom<input 		name='sv_zoomText' id='sv_zoomText' type='text' style='width:26px; border:none;' value='".$sv_zoom."'	/>
			&nbsp;
		");
	
		echo "<table>";
		echo "<tr><td align=\"center\">\n";
			echo "<form method=\"post\" action=\"\">";
			echo "&nbsp; ".$list_latlon;
			echo "<input style=\"background:white;\"type=\"submit\" name=\"Submit\" id=\"Submit\" onClick=\"update_sv_params($placeid);\" value=\"Save View\">";
			echo "</form>";
		echo "</td></tr>\n";
		echo "</table>\n";
*/
	?>
	</div>
-->

</body>  
</html>