Hi!
i want to share javascript code (get variables from URL, make url to current view)
enjoy
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
<script>
var krpano = document.getElementById("krpanoSWFObject");
function gotoscene(sc) {
var scene = sc; var ath = "0"; var atv = "0"; var fov = "100";
var vars = window.location.search.split("&");
for(j = 0; j < vars.length; j++){
if (vars[j].search("scene=") > 0) { scene = vars[j].replace("?scene=",""); }
if (vars[j].search("ath=") > 0) { ath = vars[j].replace("?ath=","") }
if (vars[j].search("atv=") > 0) { atv = vars[j].replace("?atv=",""); }
if (vars[j].search("fov=") > 0) { fov = vars[j].replace("?fov=",""); }
}
krpano.call("loadscene(" + scene + ")");
krpano.call("lookto(" + ath + "," + atv + "," + fov + ")");
}
function getlink() {
var scene = krpano.get("xml.scene");
var ath = krpano.get("view.hlookat").toFixed(2);
var atv = krpano.get("view.vlookat").toFixed(2);
var fov = krpano.get("view.fov").toFixed(2);
var link = "?scene=" + scene + "&?ath=" + ath + "&?atv=" + atv + "&?fov=" + fov;
link = window.location.protocol + window.location.pathname + link;
alert(link);
}
</script>
|
In this example I show how you can get variables from url ( example url:
http://domen.com/tour.html?scene=name&?a…?atv=5&?fov=100 )
in gotoscene function you can egt variables from url
scene = name, ath = 20, atv = 5, fov = 100;
and use it with krpano.call as you want.
getlink function create link variable as
http://domen.com/tour.html?scene=current…nt_hlooat&?atv= current_vlooat&?fov=current_fov
Hope it help to somebody
Andrey