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.

1

Mittwoch, 5. Juli 2017, 15:59

Can't use set(layer[name].url.html5,"file.js")?

Hi!
If I define the layer first like this:

Quellcode

1
2
3
4
5
6
7
8
9
10
	<!-- radar -->
	<layer name="radar" keep="true"
	       url.flash="%SWFPATH%/plugins/radar.swf"
	       url.html5="%SWFPATH%/plugins/radar.js"
	       align="center" zorder="1"
	       scale.mobile="1.5"
	       fillalpha="0.5" fillcolor="0x7F5F3F"
	       linewidth="1.0" linecolor="0xE0E0A0" linealpha="0.5"
	       editmode="true"
  />


and set the parameters with set like this:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
	<action name="create-radar">
		set(layer[radar].align,"topleft");
		set(layer[radar].mask,"mapmask");
		set(layer[radar].edge,"center");
		set(layer[radar].parent,"map");
		set(layer[radar].keep,"false");
		set(layer[radar].scale,"2");
		set(layer[radar].fillcolor,"0xFF0000");
		set(layer[radar].linewidth,"1.0");
		set(layer[radar].zorder, "2");
		set(layer[radar].editmode, "true");
	</action>


It works as expected.
But if I use addlayer(radar) to create it, it doesn't load:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
	<action name="create-radar">
		addlayer(radar);
		set(layer[radar].align,"topleft");
		set(layer[radar].mask,"mapmask");
		set(layer[radar].edge,"center");
		set(layer[radar].parent,"map");
		set(layer[radar].keep,"false");
		set(layer[radar].url.flash,"%SWFPATH%/plugins/radar.swf");
		set(layer[radar].url.html5,"%SWFPATH%/plugins/radar.js");
		set(layer[radar].scale,"2");
		set(layer[radar].fillcolor,"0xFF0000");
		set(layer[radar].linewidth,"1.0");
		set(layer[radar].zorder, "2");
		set(layer[radar].editmode, "true");
	</action>


Am I missing something?

I have my doubts on the set/get and dots.
The debug("Radar.url:",get(layer[radar].url.html5)); is throwing a null.

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »robertl« (5. Juli 2017, 16:13)


Beiträge: 770

Wohnort: Russian Federation

Beruf: Interpreting, Building virtual tours

  • Nachricht senden

2

Mittwoch, 5. Juli 2017, 16:15

hi) It won't work this way. You're trying to use static xml device check while adding the layer dynamically.

Try 'if' condition instead. Like this:

Quellcode

1
if(device.html5, set(layer[radar].url. '%SWFPATH%/plugins/radar.js'); , set(layer[radar].url. '%SWFPATH%/plugins/radar.swf'));
Regards,

Alexey

3

Mittwoch, 5. Juli 2017, 16:36

hi) It won't work this way. You're trying to use static xml device check while adding the layer dynamically.

Try 'if' condition instead. Like this:

Quellcode

1
if(device.html5, set(layer[radar].url. '%SWFPATH%/plugins/radar.js'); , set(layer[radar].url. '%SWFPATH%/plugins/radar.swf'));


Thanks Alexey!
That did the trick.

And finally found the relevant part in the documentation!
So all the additional concatenated attributes are basically shorthand if checks?

How about this:

Quellcode

1
2
  <hotspot name="pano15" videourl="%FIRSTXML%/spots/pano_high.mp4" devices="desktop" />
  <hotspot name="pano15" videourl="%FIRSTXML%/spots/pano_low.mp4" devices="tablet.or.mobile.and.no-iphone" />


That is from a live site and it's working.
It's elegant, and seems replicating it dynamically would not be as much.

I'm guessing this wouldn't work:

Quellcode

1
2
3
4
5
addlayer(pano15);
set(layer[pano15].videourl, get(%FIRSTXML%/spots/pano_high.mp4));
set(layer[pano15].devices, 'desktop');
set(layer[pano15].videourl, get(%FIRSTXML%/spots/pano_low.mp4));
set(layer[pano15].devices, 'tablet.or.mobile.and.no-iphone');


but this one could:

Quellcode

1
2
3
4
5
6
7
8
9
addlayer(pano15);
if(device.desktop,
    set(layer[pano15].videourl, get(%FIRSTXML%/spots/pano_high.mp4));
    set(layer[pano15].devices, 'desktop');
);
if(device.tablet.or.mobile.and.no-iphone,
    set(layer[pano15].videourl, get(%FIRSTXML%/spots/pano_low.mp4));
    set(layer[pano15].devices, 'tablet.or.mobile.and.no-iphone');
);

4

Sonntag, 9. Juli 2017, 17:40

Hi,

So all the additional concatenated attributes are basically shorthand if checks?
Yes, can be said. They decide if that attribute will get parsed or not.


but this one could:
addlayer(pano15);
if(device.desktop,
set(layer[pano15].videourl, get(%FIRSTXML%/spots/pano_high.mp4));
set(layer[pano15].devices, 'desktop');
);
if(device.tablet.or.mobile.and.no-iphone,
set(layer[pano15].videourl, get(%FIRSTXML%/spots/pano_low.mp4));
set(layer[pano15].devices, 'tablet.or.mobile.and.no-iphone');
);
  • the 'if' is okay
  • the 'get(...)' is wrong as the values you're setting are not variables
  • and setting the 'devices' attributes is unnecessary and wouldn't do anything. krpano checks the 'devices' attributes in the xml files only during parsing the xml data to the internal data structures.

Here an alternative one-line solution using the calc() action and the ternary (if ? then : else) operator:

Quellcode

1
calc(layer[pano15].videourl, device.desktop ? '%FIRSTXML%/spots/pano_high.mp4' : '%FIRSTXML%/spots/pano_low.mp4');
or here with separating the folder-path from the file-names:

Quellcode

1
calc(layer[pano15].videourl, '%FIRSTXML%/spots/' + (device.desktop ? pano_high.mp4' : 'pano_low.mp4'));


Best regards,
Klaus

5

Sonntag, 9. Juli 2017, 18:17

Hi,

  • the 'if' is okay
  • the 'get(...)' is wrong as the values you're setting are not variables
  • and setting the 'devices' attributes is unnecessary and wouldn't do anything. krpano checks the 'devices' attributes in the xml files only during parsing the xml data to the internal data structures.



Uh, yes, you're right about the get. I was a bit tired and didn't think it through :)
Good to know about the 'devices ' attribute, so it's like a preprocessor command?

Zitat


Here an alternative one-line solution using the calc() action and the ternary (if ? then : else) operator:

Quellcode

1
calc(layer[pano15].videourl, device.desktop ? '%FIRSTXML%/spots/pano_high.mp4' : '%FIRSTXML%/spots/pano_low.mp4');
or here with separating the folder-path from the file-names:

Quellcode

1
calc(layer[pano15].videourl, '%FIRSTXML%/spots/' + (device.desktop ? pano_high.mp4' : 'pano_low.mp4'));


Yeah, that would work.
Thanks!