<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Infinity Code Forum — Problem when zooming and panning the map at the same time]]></title>
		<link>https://forum.infinity-code.com/viewtopic.php?id=1331</link>
		<atom:link href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=1331&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Problem when zooming and panning the map at the same time.]]></description>
		<lastBuildDate>Sat, 10 Aug 2019 22:31:37 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Problem when zooming and panning the map at the same time]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=5432#p5432</link>
			<description><![CDATA[<p>Hello.</p><p>Why in this case the map goes crazy:<br />SetTilePosition uses the current zoom unless you specify which zoom to use.<br />When the integer zoom increases (decreases), the number of tiles horizontally and vertically doubles, and your tile position is not where you expect it to be.</p><p>To avoid this, SetTilePosition can take a third parameter - zoom, which you should use in this case.<br />Something like:<br /></p><div class="codebox"><pre><code>OnlineMaps.instance.SetTilePosition(pos.x, pos.y, (int)GameManager.defaultMapZoom);

// ...

private OnlineMapsVector2d GetTilePosition(Transform target)
{
// ...
    OnlineMaps.instance.projection.CoordinatesToTile (lon, lat, (int)GameManager.defaultMapZoom, out double endPosX, out double endPosY);
// ...
}

// The same goes for initPos.</code></pre></div><p>I did not write about SetTilePosition.<br />I wrote that for animation of movement it is better to use a tile position. <br />Will you use SetTilePosition or projection.TileToCoordinates + SetPosition, it doesn&#039;t matter.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Sat, 10 Aug 2019 22:31:37 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=5432#p5432</guid>
		</item>
		<item>
			<title><![CDATA[Re: Problem when zooming and panning the map at the same time]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=5431#p5431</link>
			<description><![CDATA[<p>I&#039;ve made a test using &quot;OnlineMaps.instance.SetPosition&quot;, instead of &quot;OnlineMaps.instance.SetTilePosition&quot;, and it work correctly with the map movement and map zoom.</p><p>Some post ago you wrote me that the best approach to move the map is SetTilePosition, but in this case it does not seem to work so well.</p><p>So, what should I use?<br />Many thanks!</p>]]></description>
			<author><![CDATA[null@example.com (danielesuppo)]]></author>
			<pubDate>Sat, 10 Aug 2019 18:11:13 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=5431#p5431</guid>
		</item>
		<item>
			<title><![CDATA[Problem when zooming and panning the map at the same time]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=5430#p5430</link>
			<description><![CDATA[<p>Hello,<br />if I zoom the map with a Lerp let&#039;s say from 10 to 14, and at the same time I move in the same Lerp the map (just a couple of Km) the Latitude and Longitude go crazy...<br />Just lerping the zoom, or the pan, is ok.</p><p>This is my code</p><p> while (Time.time - tm &lt;= time)<br />&nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; float t = (Time.time - tm) / time;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ///Get end tile map position<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; OnlineMapsVector2d endPos = GetTilePosition(placeholder);</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ///Lerp final position<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; OnlineMapsVector2d pos = OnlineMapsVector2d.Lerp(initPos, endPos, t);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; OnlineMaps.instance.SetTilePosition(pos.x, pos.y);</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ///If the actual map zoom level is less than the<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ///default zoom level, zoom in the map<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (OnlineMaps.instance.floatZoom &lt; defaultMapZoom)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;OnlineMaps.instance.floatZoom = Mathf.Lerp(OnlineMaps.instance.floatZoom, GameManager.defaultMapZoom, t);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; yield return null;<br />&nbsp; &nbsp; &nbsp; &nbsp; }</p><br /><p>private OnlineMapsVector2d GetTilePosition(Transform target)<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; OnlineMapsVector2d pos = new OnlineMapsVector2d();<br />&nbsp; &nbsp; &nbsp; &nbsp; if (OnlineMapsTileSetControl.instance.GetCoordsByWorldPosition<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (out double lon, out double lat, target.position))<br />&nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; OnlineMaps.instance.projection.CoordinatesToTile<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (lon, lat, OnlineMaps.instance.zoom, out double endPosX, out double endPosY);</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pos.x = endPosX;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pos.y = endPosY;<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; return pos;<br />&nbsp; &nbsp; }</p>]]></description>
			<author><![CDATA[null@example.com (danielesuppo)]]></author>
			<pubDate>Sat, 10 Aug 2019 17:03:59 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=5430#p5430</guid>
		</item>
	</channel>
</rss>
