<krpano>

	<!--
		This is an example that shows:

		- How to load custom tiles by using the 'customParseTilePath' API:
		  - https://krpano.com/docu/plugininterface/#customParseTilePath
	-->

	<include url="%VIEWER%/plugins/iphone_fullscreen_swipe.xml" />
	<include url="%VIEWER%/plugins/combobox.xml" />

	<view limitview="fullrange" maxpixelzoom="2" />
	<control zoomtocursor="true" zoomoutcursor="true" />
	<control keycodesin="16,65,107" keycodesout="17,89,90,109" />
	<network retrycount="0" />
	<events name="ignoreloadingerrors" keep="true" onloaderror=" " />


	<!-- update: access to the wikimedia map tiles is unfortunately no longer allowed...
	<scene name="wikimaps" onstart="set(view.fovmax,1);">
		<view limitview="range" maxpixelzoom="2" />
		<image maptype="wiki">
			<flat url="https://maps.wikimedia.org/osm-intl/${z}/${x}/${y}.png" multires="256,512x512,1024x1024,2048x2048,4096x4096,8192x8192,16384x16384,32768x32768,65536x65536,131072x131072,262144x262144,524288x524288,1048576x1048576,2097152x2097152,4194304x4194304,8388608x8388608,16777216x16777216,33554432x33554432,67108864x67108864,134217728x134217728" />
		</image>
		<layer name="attribution" type="text" html="Tile server [a href='https://foundation.wikimedia.org/wiki/Maps_Terms_of_Use' target='_blank']Wikimedia maps[/a] | Map data &amp;copy; [a href='https://www.openstreetmap.org/copyright' target='_blank']OpenStreetMap contributors[/a]" align="rightbottom" />
	</scene>
	-->

	<scene name="openstreetmaps"  autoload="true" onstart="set(view.fovmax,1);">
		<view limitview="range" maxpixelzoom="2" />
		<image maptype="osm" hfov="0.001">
			<flat url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" multires="256,512x512,1024x1024,2048x2048,4096x4096,8192x8192,16384x16384,32768x32768,65536x65536,131072x131072,262144x262144,524288x524288,1048576x1048576,2097152x2097152,4194304x4194304,8388608x8388608,16777216x16777216,33554432x33554432,67108864x67108864,134217728x134217728" />
		</image>
		<layer name="attribution" type="text" html="&amp;copy; [a href='http://www.openstreetmap.org/copyright' target='_blank']OpenStreetMap[/a]" align="rightbottom" />
	</scene>

	<scene name="basemap_at" onstart="set(view.fovmax,0.000017);">
		<krpano bgcolor="0xFFFFFF "/>
		<view fovtype="VFOV" fov="0.000017" fovmax="0.000017" limitview="range" hlookatmin="0.0000258" hlookatmax="0.0000478" vlookatmin="-0.000157039" vlookatmax="-0.00014523" maxpixelzoom="2" />
		<image maptype="basemap_at" hfov="0.001">
			<flat url="https://maps{s}.wien.gv.at/basemap/bmaporthofoto30cm/normal/google3857/{z}/{y}/{x}.jpeg" multires="256,4096x4096,8192x8192,16384x16384,32768x32768,65536x65536,131072x131072,262144x262144,524288x524288,1048576x1048576,2097152x2097152,4194304x4194304,8388608x8388608,16777216x16777216,33554432x33554432,67108864x67108864,134217728x134217728" />
		</image>
		<layer name="attribution" type="text" html="Datenquelle: [a href='https://www.basemap.at' target='_blank']basemap.at[/a]" align="rightbottom" />
	</scene>

	<scene name="arcgis_worldmap" onstart="set(view.fovmax,1);">
		<krpano bgcolor="0xFFFFFF "/>
		<view limitview="range" maxpixelzoom="2" />
		<image maptype="osm" hfov="0.001">
			<flat url="https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}.jpg" multires="256,512x512,1024x1024,2048x2048,4096x4096,8192x8192,16384x16384,32768x32768,65536x65536,131072x131072,262144x262144,524288x524288,1048576x1048576,2097152x2097152,4194304x4194304,8388608x8388608,16777216x16777216,33554432x33554432,67108864x67108864,134217728x134217728" />
		</image>
		<layer name="attribution" type="text" html="&amp;copy; [a href='http://goto.arcgisonline.com/maps/World_Street_Map' target='_blank']ArcGIS World Imagery[/a]" align="rightbottom" />
	</scene>

	<scene name="arcgis_streetmap" onstart="set(view.fovmax,1);">
		<krpano bgcolor="0xFFFFFF "/>
		<view limitview="range" maxpixelzoom="2" />
		<image maptype="osm" hfov="0.001">
			<flat url="https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}" multires="256,512x512,1024x1024,2048x2048,4096x4096,8192x8192,16384x16384,32768x32768,65536x65536,131072x131072,262144x262144,524288x524288,1048576x1048576,2097152x2097152,4194304x4194304,8388608x8388608,16777216x16777216,33554432x33554432,67108864x67108864,134217728x134217728" />
		</image>
		<layer name="attribution" type="text" html="&amp;copy; [a href='http://goto.arcgisonline.com/maps/World_Street_Map' target='_blank']ArcGIS Street Map[/a]" align="rightbottom" />
	</scene>

	<scene name="earth_at_night" onstart="set(view.fovmax,1);">
		<krpano bgcolor="0xFFFFFF "/>
		<view limitview="range" maxpixelzoom="2" />
		<image maptype="osm" hfov="0.001">
			<flat url="https://map1.vis.earthdata.nasa.gov/wmts-webmerc/VIIRS_CityLights_2012/default/GoogleMapsCompatible_Level8/{z}/{y}/{x}.jpg" multires="256,512x512,1024x1024,2048x2048,4096x4096,8192x8192,16384x16384,32768x32768,65536x65536" />
		</image>
		<layer name="attribution" type="text" html="&amp;copy; [a href='https://earthdata.nasa.gov/' target='_blank']NASA Earth at Night[/a]" align="rightbottom" />
	</scene>


	<!-- select the different tile providers -->
	<combobox name="mapsselection" align="righttop" x="10" y="10">
		<item name="item1" caption="OpenStreetMaps"       onclick="loadscene(openstreetmaps,null,MERGE|KEEPVIEW,BLEND(0.5));" />
		<item name="item2" caption="ArcGIS World Imagery" onclick="loadscene(arcgis_worldmap,null,MERGE|KEEPVIEW,BLEND(0.5));" />
		<item name="item3" caption="ArcGIS Street Map"    onclick="loadscene(arcgis_streetmap,null,MERGE|KEEPVIEW,BLEND(0.5));" />
		<item name="item4" caption="Earth at Night"       onclick="loadscene(earth_at_night,null,MERGE|KEEPVIEW,BLEND(0.5));" />
		<item name="item5" caption="basemap.at"           onclick="loadscene(basemap_at,null,MERGE|KEEPVIEW,BLEND(0.5));" />
	</combobox>



	<!-- Extend krpano with support for loading map tiles -->
	<action type="Javascript" autorun="preinit"><![CDATA[

		// parse tile urls
		krpano.customParseTilePath = function(path, cubeside, level, h, v, stereo, image)
		{
			if (image.maptype == "wiki")
			{
				// WikiMaps tile placeholders
				path = path.split("${x}").join(1*h-1);
				path = path.split("${y}").join(1*v-1);
				path = path.split("${z}").join(1*level);
			}
			else if (image.maptype == "osm")
			{
				// OpenStreetMap tile placeholders
				path = path.split("{s}").join( "abc"[(Math.random()*3)|0] );
				path = path.split("{x}").join(1*h-1);
				path = path.split("{y}").join(1*v-1);
				path = path.split("{z}").join(1*level);
			}
			else if (image.maptype == "basemap_at")
			{
				// Basemap.at tile placeholders
				path = path.split("{s}").join( ["","1","2","3","4"][(Math.random()*5)|0] );
				path = path.split("{x}").join(1*h-1);
				path = path.split("{y}").join(1*v-1);
				path = path.split("{z}").join(1*level+3);
			}

			return path;
		}

	]]></action>

</krpano>
