<?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 — Smooth Zoom]]></title>
		<link>https://forum.infinity-code.com/viewtopic.php?id=23</link>
		<atom:link href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=23&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Smooth Zoom.]]></description>
		<lastBuildDate>Thu, 14 Apr 2016 11:21:06 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Smooth Zoom]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=582#p582</link>
			<description><![CDATA[<p>Example attached.<br />Unfortunately, I do not know what ATween, so I used iTween.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Thu, 14 Apr 2016 11:21:06 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=582#p582</guid>
		</item>
		<item>
			<title><![CDATA[Re: Smooth Zoom]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=579#p579</link>
			<description><![CDATA[<p>Hey... I tried your example with no success...<br />I&#039;m trying to smoothly zoom into a certain location while the map moves using a tween that updates the values (&quot;ATween.FloatTo&quot;). I&#039;ve spent the whole afternoon on this and did not work... My last try was using this:</p><div class="codebox"><pre><code>public void FocusUserLocation(bool p_tweenEnabled, int p_zoomLevel = 16, float p_duration = 0.5f, ATweenEase p_easeType = ATweenEase.CUBIC_IN_OUT, Action p_callback = null)
    {
        
        Vector2 __userLocation = RetrieveGPSData();

        if (p_tweenEnabled)
        {
            if (focusTweenNodule == null)
            {
                Vector2 __mapPosition;
                double __lng = 0.0;
                double __lat = 0.0;
                Vector2 localPoint;
                RectTransform rectTransform = GameObject.FindWithTag(&quot;NavigateScreen&quot;).GetComponent&lt;RectTransform&gt;();
                RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, Input.mousePosition,
                    Camera.main, out localPoint);

                Rect mapRect = rectTransform.rect;
                Vector2 defPivot = rectTransform.pivot;
                Vector2 defSize = rectTransform.sizeDelta;
                Vector2 defPosition = rectTransform.anchoredPosition;
                Vector2 initialPosition = __userLocation;

                Vector2 pivot = new Vector2();
                float ox = localPoint.x + mapRect.width * defPivot.x;
                float oy = localPoint.y + mapRect.height * defPivot.y;
                pivot.x = ox / mapRect.width;
                pivot.y = oy / mapRect.height;

                float initialDistance = (GetMapLocation() - __userLocation).magnitude;

                Vector2 offsetMax = rectTransform.offsetMax;
                Vector2 offsetMin = rectTransform.offsetMin;
                rectTransform.pivot = pivot;
                rectTransform.offsetMax = offsetMax;
                rectTransform.offsetMin = offsetMin;

                _isUserLocationFocusActive = true;
                onlineMaps.GetPosition(out __lng, out __lat);
                __mapPosition = new Vector2((float)__lng, (float)__lat);
                focusTweenNodule = ATween.Vector2To(__mapPosition, __userLocation, p_duration, p_easeType, delegate(Vector2 p_updatePosition)
                {
                    float distance = (p_updatePosition - __userLocation).magnitude;
                    float a = distance / initialDistance;
                    onlineMaps.transform.localScale = new Vector3(a, a, a);
                    FocusLocation(p_updatePosition.x, p_updatePosition.y);
                });
                focusTweenNodule.onFinished += delegate
                {
                    if (p_callback != null)
                        p_callback();

                    onlineMaps.transform.localScale = Vector3.one;
                    onlineMaps.zoom = p_zoomLevel;
                    focusTweenNodule = null;
                    _isUserLocationFocusActive = false;
                };
            }
        }
        else
        {
            FocusLocation(__userLocation.x, __userLocation.y);
            onlineMaps.zoom = p_zoomLevel;

            if (p_callback != null)
                p_callback();
        }
    }

    public void FocusLocation(float p_longitude, float p_latidude)
    {
        OnlineMaps.instance.SetPosition((double)p_longitude, (double)p_latidude);
    }</code></pre></div><p>I didn&#039;t get what RectTransform I have to use, because the map is not in a canvas. In this code I used a RectTransform from an object (&quot;NavigateScreen&quot;) that is in a canvas, but it&#039;s not the map&#039;s object itself.<br />Please, I need a light on this <img src="https://forum.infinity-code.com/img/smilies/tongue.png" width="15" height="15" alt="tongue" /></p>]]></description>
			<author><![CDATA[null@example.com (felipeberquo)]]></author>
			<pubDate>Wed, 13 Apr 2016 17:50:57 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=579#p579</guid>
		</item>
		<item>
			<title><![CDATA[Re: Smooth Zoom]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=578#p578</link>
			<description><![CDATA[<p>Right, it&#039;s more clear now! I will try this way, thx!</p>]]></description>
			<author><![CDATA[null@example.com (felipeberquo)]]></author>
			<pubDate>Tue, 12 Apr 2016 19:46:20 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=578#p578</guid>
		</item>
		<item>
			<title><![CDATA[Re: Smooth Zoom]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=577#p577</link>
			<description><![CDATA[<p>Hello.</p><p>First you need to set the pivot (see example above, StartSmoothZoom method).<br />Next you just change «rectTransform.localScale» to emulate the smooth zoom.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Tue, 12 Apr 2016 18:54:27 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=577#p577</guid>
		</item>
		<item>
			<title><![CDATA[Re: Smooth Zoom]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=574#p574</link>
			<description><![CDATA[<p>Hey, I want to achieve a smooth zoom to but programmatically, using a script, <strong>not</strong> the mouse or touch inputs... I searched the forum for an answer and found this thread. I took a look at you example script and did not see how I could use it to achieve my goal... I need to &quot;tween&quot; the map zoom smoothly (i.e., updating the zoom with a float value).<br />I&#039;m using Tilesets.</p>]]></description>
			<author><![CDATA[null@example.com (felipeberquo)]]></author>
			<pubDate>Tue, 12 Apr 2016 14:28:03 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=574#p574</guid>
		</item>
		<item>
			<title><![CDATA[Re: Smooth Zoom]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=68#p68</link>
			<description><![CDATA[<p>Got it. Thanks</p>]]></description>
			<author><![CDATA[null@example.com (ali.arslan)]]></author>
			<pubDate>Fri, 21 Aug 2015 04:37:17 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=68#p68</guid>
		</item>
		<item>
			<title><![CDATA[Re: Smooth Zoom]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=67#p67</link>
			<description><![CDATA[<p>Hello.</p><p>Smooth zoom is available in tileset.<br />For other controls you need to make it yourself using Online Maps API.<br />Example of smooth zoom for uGUI is attached.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Mon, 17 Aug 2015 19:01:35 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=67#p67</guid>
		</item>
		<item>
			<title><![CDATA[Smooth Zoom]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=66#p66</link>
			<description><![CDATA[<p>Hi Alex,</p><p>Currently the zoom behaviour of the map is limited to integer values. Its either zoomed at level 18 or at 17. So if we zoom out, it switches to a lower zoom level immediately. Would it be possible to make zoom fluid like we see on Google Maps or Apple Maps application?</p><p>Regards,</p><p>Ali Arslan</p>]]></description>
			<author><![CDATA[null@example.com (ali.arslan)]]></author>
			<pubDate>Mon, 17 Aug 2015 10:58:34 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=66#p66</guid>
		</item>
	</channel>
</rss>
