Topic: Smooth Zoom

Hi Alex,

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?

Regards,

Ali Arslan

Re: Smooth Zoom

Hello.

Smooth zoom is available in tileset.
For other controls you need to make it yourself using Online Maps API.
Example of smooth zoom for uGUI is attached.

Post's attachments

Attachment icon uGUISmoothZoom.cs 4.58 kb, 229 downloads since 2015-08-17 

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Smooth Zoom

Got it. Thanks

Re: Smooth Zoom

Hey, I want to achieve a smooth zoom to but programmatically, using a script, not 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 "tween" the map zoom smoothly (i.e., updating the zoom with a float value).
I'm using Tilesets.

Re: Smooth Zoom

Hello.

First you need to set the pivot (see example above, StartSmoothZoom method).
Next you just change «rectTransform.localScale» to emulate the smooth zoom.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Smooth Zoom

Right, it's more clear now! I will try this way, thx!

Re: Smooth Zoom

Hey... I tried your example with no success...
I'm trying to smoothly zoom into a certain location while the map moves using a tween that updates the values ("ATween.FloatTo"). I've spent the whole afternoon on this and did not work... My last try was using this:

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("NavigateScreen").GetComponent<RectTransform>();
                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);
    }

I didn'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 ("NavigateScreen") that is in a canvas, but it's not the map's object itself.
Please, I need a light on this tongue

Re: Smooth Zoom

Example attached.
Unfortunately, I do not know what ATween, so I used iTween.

Post's attachments

Attachment icon TweenInOut.cs 2.51 kb, 234 downloads since 2016-04-14 

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.