<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Infinity Code Forum — Smooth Zoom]]></title>
	<link rel="self" href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=23&amp;type=atom" />
	<updated>2016-04-14T11:21:06Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.infinity-code.com/viewtopic.php?id=23</id>
		<entry>
			<title type="html"><![CDATA[Re: Smooth Zoom]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=582#p582" />
			<content type="html"><![CDATA[<p>Example attached.<br />Unfortunately, I do not know what ATween, so I used iTween.</p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2016-04-14T11:21:06Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=582#p582</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Smooth Zoom]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=579#p579" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[felipeberquo]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=59</uri>
			</author>
			<updated>2016-04-13T17:50:57Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=579#p579</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Smooth Zoom]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=578#p578" />
			<content type="html"><![CDATA[<p>Right, it&#039;s more clear now! I will try this way, thx!</p>]]></content>
			<author>
				<name><![CDATA[felipeberquo]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=59</uri>
			</author>
			<updated>2016-04-12T19:46:20Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=578#p578</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Smooth Zoom]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=577#p577" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2016-04-12T18:54:27Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=577#p577</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Smooth Zoom]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=574#p574" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[felipeberquo]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=59</uri>
			</author>
			<updated>2016-04-12T14:28:03Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=574#p574</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Smooth Zoom]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=68#p68" />
			<content type="html"><![CDATA[<p>Got it. Thanks</p>]]></content>
			<author>
				<name><![CDATA[ali.arslan]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=20</uri>
			</author>
			<updated>2015-08-21T04:37:17Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=68#p68</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Smooth Zoom]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=67#p67" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2015-08-17T19:01:35Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=67#p67</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Smooth Zoom]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=66#p66" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[ali.arslan]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=20</uri>
			</author>
			<updated>2015-08-17T10:58:34Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=66#p66</id>
		</entry>
</feed>
