<?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 — Center map on marker, but within a smaller rect]]></title>
		<link>https://forum.infinity-code.com/viewtopic.php?id=2209</link>
		<atom:link href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=2209&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Center map on marker, but within a smaller rect.]]></description>
		<lastBuildDate>Thu, 22 Feb 2024 10:06:16 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Center map on marker, but within a smaller rect]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=9413#p9413</link>
			<description><![CDATA[<p>Thank you. Working perfectly.</p>]]></description>
			<author><![CDATA[null@example.com (mikli1)]]></author>
			<pubDate>Thu, 22 Feb 2024 10:06:16 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=9413#p9413</guid>
		</item>
		<item>
			<title><![CDATA[Re: Center map on marker, but within a smaller rect]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=9412#p9412</link>
			<description><![CDATA[<p>What needs to change:<br /></p><div class="codebox"><pre><code>ty -= offsetY / OnlineMapsUtils.tileSize * map.zoomFactor; // For v3.8 and earlier: zoomCoof.</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Wed, 21 Feb 2024 13:26:30 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=9412#p9412</guid>
		</item>
		<item>
			<title><![CDATA[Re: Center map on marker, but within a smaller rect]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=9407#p9407</link>
			<description><![CDATA[<p>Hello.&nbsp; I&#039;m currently on a business trip in another country.&nbsp; I&#039;ll be back in a couple of days and answer your question.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Mon, 19 Feb 2024 14:06:31 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=9407#p9407</guid>
		</item>
		<item>
			<title><![CDATA[Re: Center map on marker, but within a smaller rect]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=9406#p9406</link>
			<description><![CDATA[<p>Hello, I&#039;ve just discovered a problem with this solution. <br />On mobile device with pinch to zoom it is possible that map zoom is not an integer. In these cases the CoordinatesToTile method returns incorrect result, because it is casting the map zoom into an integer. In the editor the map zoom is always an integer (excluding the smooth zoom), and the problem is not occuring in the editor.</p><p>Is there any way I can fix that? If I change the CoordinatesToTile zoom parameter to float, how can I calculate the mapSize in mercator projection?</p><div class="codebox"><pre><code>long mapSize = (long)OnlineMapsUtils.tileSize &lt;&lt; zoom;</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (mikli1)]]></author>
			<pubDate>Mon, 19 Feb 2024 08:13:31 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=9406#p9406</guid>
		</item>
		<item>
			<title><![CDATA[Re: Center map on marker, but within a smaller rect]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=9295#p9295</link>
			<description><![CDATA[<p>This is most likely due to the fact that you are setting zoom to 14.<br />In the method you calculate the shift in pixels based on the current zoom, which will be different for each zoom level.<br />To make this constant, calculate the shift for zoom - 14.</p><p>Just make a tween from the current zoom to the desired zoom.<br />This can be done with any tween framework or manually in Update using Lerp.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Fri, 08 Dec 2023 09:02:16 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=9295#p9295</guid>
		</item>
		<item>
			<title><![CDATA[Re: Center map on marker, but within a smaller rect]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=9294#p9294</link>
			<description><![CDATA[<p>Holy smokes. Thank you for that. Now it is working fine... but not always. Clicking on the same marker should always get the same results, but it is not the case. When I start the app the first click is always wrong. Then it is correct, but also it happens that the result is incorrect... I don&#039;t know what&#039;s happening there. It seems to me that when I zoom out the map and click the result is always wrong.</p><p>That is connected to the next thing I would like to ask:</p><p>I would like to zoom it smoothly to the marker. Is there a way to do that?<br />map.zoom = 14 just jumps to that zoom immediately and it breaks further calculations of center on marker.</p>]]></description>
			<author><![CDATA[null@example.com (mikli1)]]></author>
			<pubDate>Fri, 08 Dec 2023 07:38:35 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=9294#p9294</guid>
		</item>
		<item>
			<title><![CDATA[Re: Center map on marker, but within a smaller rect]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=9293#p9293</link>
			<description><![CDATA[<p>This is because in CoordinatesToTile (and the rest of API) the longitude of the first is expected.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Thu, 07 Dec 2023 19:52:21 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=9293#p9293</guid>
		</item>
		<item>
			<title><![CDATA[Re: Center map on marker, but within a smaller rect]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=9292#p9292</link>
			<description><![CDATA[<p>Thanks for quick reply. The problem is that I&#039;m using UI markers manager and my markers don&#039;t inherit from OnlineMapsMarkerBase. I guess that is an important detail I&#039;ve forgot to mention.</p><p>How can I convert longitude and latitude to the tile position?</p><p>EDIT. I can use map.projection.CoordinatesToTile I guess. I&#039;ll try it.</p><p>I&#039;m getting wierd results. It moves the map to far-away place. My code:</p><br /><div class="codebox"><pre><code>public void CenterOnMarker(double latitude, double longitude, float offsetY = 0)
{
    OnlineMaps map = OnlineMaps.instance;
    Debug.Log(&quot;Map position before: &quot; + map.position);
    Debug.Log(&quot;Center on marker: &quot; + latitude + &quot; &quot; + longitude + &quot; offset: &quot; + offsetY + &quot;  map zoom: &quot; + map.zoom);

    map.projection.CoordinatesToTile(latitude, longitude, map.zoom, out double tx, out double ty);
    Debug.Log(&quot;tx: &quot; + tx + &quot; ty: &quot; + ty + &quot;   tileSize: &quot; + OnlineMapsUtils.tileSize);
    ty -= offsetY / OnlineMapsUtils.tileSize;
    map.SetTilePosition(tx, ty);
    map.zoom = 14;

    Debug.Log(&quot;Map position after: &quot; + map.position);
}</code></pre></div><p>The logs im getting:<br /></p><div class="codebox"><pre><code>Map position before: (16.95, 52.40)
Center on marker: 52,41 16,91 offset: 209,44  map zoom: 12
tx: 2644,31128645833 ty: 1852,74819069953   tileSize: 256
Map position after: (24.00, 49.00)</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (mikli1)]]></author>
			<pubDate>Thu, 07 Dec 2023 15:33:28 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=9292#p9292</guid>
		</item>
		<item>
			<title><![CDATA[Re: Center map on marker, but within a smaller rect]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=9291#p9291</link>
			<description><![CDATA[<p>Hello.</p><p>Something like that:<br /></p><div class="codebox"><pre><code>/// &lt;summary&gt;
/// Centers the map on the marker with the specified vertical offset in pixels.
/// &lt;/summary&gt;
/// &lt;param name=&quot;marker&quot;&gt;Marker&lt;/param&gt;
/// &lt;param name=&quot;offsetY&quot;&gt;Vertical offset in pixels&lt;/param&gt;
private void CenterOnMarker(OnlineMapsMarkerBase marker, float offsetY = 0)
{
    OnlineMaps map = OnlineMaps.instance;
    double tx, ty;
    marker.GetTilePosition(map.zoom, out tx, out ty);
    ty -= offsetY / OnlineMapsUtils.tileSize;
    map.SetTilePosition(tx, ty);
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Thu, 07 Dec 2023 15:24:48 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=9291#p9291</guid>
		</item>
		<item>
			<title><![CDATA[Center map on marker, but within a smaller rect]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=9289#p9289</link>
			<description><![CDATA[<p>I have the map on fullscreen with markers (vertical orientation). When I select a marker I have a popup that takes the bottom half of the screen. Is there a way I can center the map on the selected marker but within the remaining space for map? I know there is a method GetCenterPointAndZoom but it does not allow to pass the rect bounds.</p><p>Thanks for help.</p>]]></description>
			<author><![CDATA[null@example.com (mikli1)]]></author>
			<pubDate>Thu, 07 Dec 2023 15:03:52 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=9289#p9289</guid>
		</item>
	</channel>
</rss>
