this
._map =
new
GMap2(
document.getElementById(
"map"
));
this
._map.setUIToDefault();
this
._map.setCenter(
new
GLatLng(lat, lng), 17);
this
._guyIcon =
new
GIcon(G_DEFAULT_ICON);
this
._guyIcon.image =
this
._guyIcon.transparent =
this
._guyIcon.imageMap = [
26, 13, 30, 14, 32, 28, 27, 28,
28, 36, 18, 35, 18, 27, 16, 26,
16, 20, 16, 14, 19, 13, 22, 8];
this
._guyIcon.iconSize =
new
GSize(49, 52);
this
._guyIcon.iconAnchor =
new
GPoint(25, 35);
this
._svOverlay =
new
GStreetviewOverlay();
this
._map.addOverlay(
this
._svOverlay);
this
._streetViewClient =
new
GStreetviewClient();
this
._streetViewer =
new
GStreetviewPanorama(
document.getElementById(
"stview"
));
this
._direction =
new
GDirections();
GEvent.addListener(
this
._direction,
"load"
,
function
() {
var
p =
this
._direction.getPolyline().getVertex(0);
var
mystv =
this
;
this
._streetViewClient.getNearestPanorama(p,
function
(panoData) { mystv._showPanoData(panoData); });
});
_showPanoData:
function
(panoData) {
this
._streetViewer.setLocationAndPOV(
panoData.location.latlng);
if
(!
this
._guyMarker) {
this
._guyMarker =
new
GMarker(panoData.location.latlng,
{ icon:
this
._guyIcon, draggable:
true
});
this
._map.addOverlay(
this
._guyMarker);
var
mystv =
this
;
GEvent.addListener(
this
._guyMarker,
"dragend"
,
function
() { mystv._onDragEnd(); });
}
else
{
this
._guyMarker.setLatLng(panoData.location.latlng);
}
}
_onDragEnd:
function
() {
var
latlng =
this
._guyMarker.getLatLng();
this
._direction.loadFromWaypoints(
[latlng.toUrlValue(6), latlng.toUrlValue(6)],
{ getPolyline:
true
});
}