<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Infinity Code Forum — Rotate the camera by compass when online map is sprite render.]]></title>
	<link rel="self" href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=750&amp;type=atom" />
	<updated>2018-01-24T13:46:41Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.infinity-code.com/viewtopic.php?id=750</id>
		<entry>
			<title type="html"><![CDATA[Re: Rotate the camera by compass when online map is sprite render.]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=3265#p3265" />
			<content type="html"><![CDATA[<p>Great!!! Thank you!!!</p>]]></content>
			<author>
				<name><![CDATA[drand]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=588</uri>
			</author>
			<updated>2018-01-24T13:46:41Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=3265#p3265</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Rotate the camera by compass when online map is sprite render.]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=3264#p3264" />
			<content type="html"><![CDATA[<p>We have slightly improved this method.<br />Now this should work better for you.<br />The next version will contain this.</p><p>OnlineMapsSpriteRendererControl.GetScreenPosition:<br /></p><div class="codebox"><pre><code>public override Vector2 GetScreenPosition(double lng, double lat)
{
    double tlx, tly, brx, bry;
    map.GetTileCorners(out tlx, out tly, out brx, out bry);
    int maxX = 1 &lt;&lt; map.zoom;
    if (tlx &gt; brx) brx += maxX;

    double px, py;
    map.projection.CoordinatesToTile(lng, lat, map.zoom, out px, out py);

    if (px + maxX / 2 &lt; tlx) px += maxX;

    double rx = (px - tlx) / (brx - tlx) - 0.5;
    double ry = 0.5 - (py - tly) / (bry - tly);

    Bounds bounds = spriteRenderer.sprite.bounds;
    Vector3 size = bounds.size;

    rx *= size.x;
    ry *= size.y;

    Vector3 worldPoint = transform.localToWorldMatrix.MultiplyPoint(new Vector3((float)rx, (float)ry, bounds.center.z));
    return Camera.main.WorldToScreenPoint(worldPoint);
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2018-01-24T13:01:32Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=3264#p3264</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Rotate the camera by compass when online map is sprite render.]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=3256#p3256" />
			<content type="html"><![CDATA[<p>The problem was in that I should remake texture for the map and started work correctly. But now I have a new problem. When markers are behind the screen this function gives me wrong coordinates. I have to draw a polygon on this markers, so when I drag the map and markers change coordinates into the wrong, the polygon has wrong sides.</p>]]></content>
			<author>
				<name><![CDATA[drand]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=588</uri>
			</author>
			<updated>2018-01-23T14:48:48Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=3256#p3256</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Rotate the camera by compass when online map is sprite render.]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=3244#p3244" />
			<content type="html"><![CDATA[<p>I made a simple script, and it works correctly for me.<br />Please check your script. Maybe it works incorrectly, because in the old version of Online Maps this method did not work correctly?!</p><p>Script:<br /></p><div class="codebox"><pre><code>using UnityEngine;

public class LogCoordinatesUnderCursor:MonoBehaviour
{
    private void OnGUI()
    {
        Vector2 coords = OnlineMapsControlBase.instance.GetCoords();

        GUIStyle style = new GUIStyle(GUI.skin.label);
        style.fontSize = 24;
        style.normal.textColor = Color.red;

        GUILayout.Label(&quot;Top Left: &quot; + OnlineMaps.instance.topLeftPosition.ToString(&quot;F6&quot;), style);
        GUILayout.Label(&quot;Bottom Right: &quot; + OnlineMaps.instance.bottomRightPosition.ToString(&quot;F6&quot;), style);
        GUILayout.Label(&quot;Coords: &quot; + coords.ToString(&quot;F6&quot;), style);
        GUILayout.Label(&quot;Input: &quot; + OnlineMapsControlBase.instance.GetInputPosition(), style);
        GUILayout.Label(&quot;Screen Position: &quot; + OnlineMapsControlBase.instance.GetScreenPosition(coords), style);
    }
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2018-01-22T17:50:04Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=3244#p3244</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Rotate the camera by compass when online map is sprite render.]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=3239#p3239" />
			<content type="html"><![CDATA[<p>Thanks for plugin update! But it looks like OnlineMapsControlBase.instance.GetScreenPosition function gives me wrong data now. I use it for calculation markers coordinates in world space.</p>]]></content>
			<author>
				<name><![CDATA[drand]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=588</uri>
			</author>
			<updated>2018-01-22T13:34:51Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=3239#p3239</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Rotate the camera by compass when online map is sprite render.]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=3237#p3237" />
			<content type="html"><![CDATA[<p>Great!!! Thanks! Waiting for update.</p>]]></content>
			<author>
				<name><![CDATA[drand]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=588</uri>
			</author>
			<updated>2018-01-20T09:40:33Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=3237#p3237</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Rotate the camera by compass when online map is sprite render.]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=3236#p3236" />
			<content type="html"><![CDATA[<p>Hello.</p><p>The problem is fixed.<br />The new version will be available through the built-in update system within two days.</p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2018-01-19T20:03:12Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=3236#p3236</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Rotate the camera by compass when online map is sprite render.]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=3234#p3234" />
			<content type="html"><![CDATA[<p>Is it possible to rotate the camera by the compass when I use sprite render for map and my own system for markers? I was tried to do it, but markers showing in wrong places when I rotate the camera.</p>]]></content>
			<author>
				<name><![CDATA[drand]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=588</uri>
			</author>
			<updated>2018-01-19T09:59:33Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=3234#p3234</id>
		</entry>
</feed>
