Sie sind nicht angemeldet.

Lieber Besucher, herzlich willkommen bei: krpano.com Forum. Falls dies Ihr erster Besuch auf dieser Seite ist, lesen Sie sich bitte die Hilfe durch. Dort wird Ihnen die Bedienung dieser Seite näher erläutert. Darüber hinaus sollten Sie sich registrieren, um alle Funktionen dieser Seite nutzen zu können. Benutzen Sie das Registrierungsformular, um sich zu registrieren oder informieren Sie sich ausführlich über den Registrierungsvorgang. Falls Sie sich bereits zu einem früheren Zeitpunkt registriert haben, können Sie sich hier anmelden.

tommo77funk

Fortgeschrittener

  • »tommo77funk« ist der Autor dieses Themas

Beiträge: 159

Wohnort: London

Beruf: Photographer

  • Nachricht senden

1

Sonntag, 12. Dezember 2010, 22:32

add spots to a map via html

HI,

I am trying to add spots to a map via html, and have tried the following example http://krpano.com/forum/wbb/index.php?pa…ot%27#post17734

but just cant get it to work for me, so I'd really appreciate if someone could offer any advice.

My preferred route is by addVariable, like

Quellcode

1
2
viewer.addVariable('set.plugin[map].addspot(spot1, 51.5055847, -0.0754774, 90, true);'); 
viewer.addVariable('set.plugin[map].updatespots();');


I can set map coord's this way but not addspot, e.g

http://www.panoraks.co.uk/googlemaps-outside-pano/

but of course am happy to use anything that works :)


Thanks and best wishes,

tom

tommo77funk

Fortgeschrittener

  • »tommo77funk« ist der Autor dieses Themas

Beiträge: 159

Wohnort: London

Beruf: Photographer

  • Nachricht senden

2

Mittwoch, 5. Januar 2011, 02:20

Hi Kaus and all,

I made another example code to try and add a mapspot via html based upon code found here http://krpano.com/forum/wbb/index.php?pa…ot%27#post17734


[url]http://www.panoraks.co.uk/googlemaps-outside-pano/index1.html
[/url]

I'd be mega grateful to anyone who can advise me a way to do this, I've been tinkering and tinkering with this for over a month and just cant get it to work *cry*

Dont suppose anyone has an idea *w00t* ?

Best wishes,

tom

Zephyr

Profi

Beiträge: 1 003

Wohnort: Netherlands

Beruf: Web developer

  • Nachricht senden

3

Mittwoch, 5. Januar 2011, 08:33

You could try an onload javascript function

Quellcode

1
2
3
4
5
6
7
8
9
10
11
<script type="text/javascript">
document.onload = addMapspot();
function addMapspot(){
	krpano().call("plugin[map].addspot(spot1, 51.5055847, -0.0754774, 90, true)");
	krpano().call("plugin[map].updatespots()");	
}
function krpano() 
{
	return document.getElementById("krpanoSWFObject");
}
</script>


or you could set a variable to true through html
viewer.addVariable("plugin[map].var1", "1");

and then in krpano an onloaded event

Quellcode

1
2
3
4
5
6
7
<events onloaded="loadmap()" />
<action name="loadmap">
if(plugin[map].var1 EQ 1,
     plugin[map].addspot(spot1, 51.5055847, -0.0754774, 90, true);
    plugin[map].updatespots();
);
</action>

tommo77funk

Fortgeschrittener

  • »tommo77funk« ist der Autor dieses Themas

Beiträge: 159

Wohnort: London

Beruf: Photographer

  • Nachricht senden

4

Mittwoch, 5. Januar 2011, 14:48

Hi,

Thank you so much for your help Zephyr, really appreciate it, nice one *thumbsup* !!!

I set up an example with your code and tried something else (commented out) but still no joy, it certainly is a tricky thing, I need to do it via html as it is part of a bigger thing that I am hoping will be helpful to pano photographers. This is the last thing that I need to do, so will show you and credit your help very soon.

http://www.panoraks.co.uk/googlemaps-out…ano/index2.html

I dont suppose a possible solution is to give the lat + long values in a function or declare with a variable that can then be returned in the googlemaps.xml

function lat(){
set('plugin[map].lat',"51.5055847");
/* lat = 51.5055847
document.write("51.5055847"); */
}


and then have this in my googlemaps.xml

<spot name="spot1"
lat="js(lat());" lng="js(long());" heading="js(head());"
/>

and return a js value or a variable for the lat, long and heading?

Just an idea, one of many *unsure*

I'll keep pluggin away, but if anyone thinks of anything, please let me know.

Thanks and best wishes,

tom

Zephyr

Profi

Beiträge: 1 003

Wohnort: Netherlands

Beruf: Web developer

  • Nachricht senden

5

Mittwoch, 5. Januar 2011, 15:32

try this:

Quellcode

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
<!DOCTYPE html>
<html>
<head>
	<title>krpano google maps example</title>
	<meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />
	<style>
		html { height:100%; }
		body { height:100%; overflow: hidden; margin:0; padding:0; font-family:Arial, Helvetica, sans-serif; font-size:16px; color:#FFFFFF; background-color:#000000; }
		a{ color:#AAAAAA; text-decoration:underline; }
		a:hover{ color:#FFFFFF; text-decoration:underline; }
	</style>
	<script type="text/javascript">
	function krpano() 
	{
		return document.getElementById("krpanoSWFObject");
	}
	
	document.onload = addMapspot();
	function addMapspot(){
		krpano().call("trace('adding spot')");
		krpano().call("plugin[map].addspot(spot1, 51.5055847, -0.0754774, 90, true)");
		krpano().call("plugin[map].updatespots()");	
	}
	</script>
</head>
<body>
<!-- test link -->
<a href="javascript:addMapspot()" target="_parent">add a spot</a>
<!-- krpano container-->
<div id="krpanoDIV" style="width:100%; height:100%;">
	<noscript><table width="100%" height="100%"><tr valign="middle"><td><center>ERROR:<br/><br/>Javascript not activated<br/><br/></center></td></tr></table></noscript>
</div>
<!-- add krpano -->
<script src="swfkrpano.js"></script>
<script type="text/javascript">
	var viewer = createPanoViewer({swf:"krpano.swf"});
	viewer.addVariable("xml", "pano1.xml");
	viewer.addVariable("setview", "true");
	viewer.addVariable("progress.showwait", "none");
	viewer.addVariable("progress.showload", "none");
	viewer.addParam("allowfullscreen", "true");
	viewer.addParam("allowscriptaccess", "always");
	viewer.embed("krpanoDIV");
</script>

</body>
</html>


btw, don't think krpano can fetch returned values. But you can execute a js function and let js set a value (btw returning a value is done with return, not document.write).

this is how I solved a cache problem

in krpano xml:

Quellcode

1
<events onloaded="js(getrandomvalue());" />


in javascript:

Quellcode

1
2
3
4
5
6
7
8
function getrandomvalue()
{
	krpano = document.getElementById('krpanoSWFObject');
	var today = new Date();
	var fivemin = 1000 * 60 * 5;
	var randy = Math.ceil(today.getTime()/(fivemin));
	krpano.set('timestamp', randy);
}

"timestamp" is a random name I made up. krpano executes getrandomvalue, then javascript sets a new variable in krpano with the randomvalue, which get read within another function by calling

Quellcode

1
%$timestamp%


example:

Quellcode

1
<include url="include/settings.xml?%$timestamp%" /> 

tommo77funk

Fortgeschrittener

  • »tommo77funk« ist der Autor dieses Themas

Beiträge: 159

Wohnort: London

Beruf: Photographer

  • Nachricht senden

6

Mittwoch, 5. Januar 2011, 16:39

Zephyr, BRILLIANT !!!!! it works your example, here :)


http://www.panoraks.co.uk/googlemaps-out…ano/index3.html

but only after clicking the map spot link,

if I use just

function krpano()
{
return document.getElementById("krpanoSWFObject");
}

document.onload = addMapspot();

function addMapspot(){
krpano().call("plugin[map].addspot(spot1, 51.5055847, -0.0754774, 90, true)");
krpano().call("plugin[map].updatespots()");
}

should'nt this line document.onload = addMapspot(); load it automatically ?

I also tried

viewer.addVariable("events.onloadcomplete", "js( addMapspot() );");

and

<body onLoad="addMapspot();">

to load it automatically.

I dont suppose you can push my happiness beyond the stratisphere and help me to load this function automatically ?

Thank you so much for your help again, *thumbup*

best wishes,

tom

tommo77funk

Fortgeschrittener

  • »tommo77funk« ist der Autor dieses Themas

Beiträge: 159

Wohnort: London

Beruf: Photographer

  • Nachricht senden

7

Mittwoch, 5. Januar 2011, 17:17

Ah ha !!! I can do onmapready="js(addMapspot());" in the googlemaps.xml !!!! and it works - wiiKed ! *thumbsup*

I AM VERY *g* *g* *g*

Thank you very much Zephyr !!!

best wishes and happy new year !!!

tom

Zephyr

Profi

Beiträge: 1 003

Wohnort: Netherlands

Beruf: Web developer

  • Nachricht senden

8

Mittwoch, 5. Januar 2011, 20:05

yes, the problem lies in the fact that a document.ready is an event that gets trigger when the html page is loaded. This doesn't include krpano xml and plugins and images. What happens is that the function gets executed before krpano is loaded. Doing a onloaded or onmapready, ensures that the function gets executed when krpano is ready. :)

What you could do is create a container function. You fire 1 function when krpano is done loading (onloaded="js(init())") then in that init you fire everything you want to krpano. If you don't need to do anything, the leave init() empty, this way stuff stays flexible for your html commands.