Re: Smooth-er zoom

Hello.

The new version is already available through the built-in update system (channel - beta).
Try to use it with Render in Thread - OFF.

Kind Regards,
Infinity Code Team

Re: Smooth-er zoom

Hello Alex,

it works! This allow us to go ahead supporting maps in our application.

However, I will wait for the full implementation! wink


Thanks for you support.

Regards

Enrico

28 (edited by Pidgie 2018-04-12 04:06:32)

Re: Smooth-er zoom

Hi there,

Just wondering if there was any update on the float zoom feature that was mentioned before.

I'm working on a feature that allows a user to click on one of several markers on interest then, ideally, the view should smoothly zoom in until the area around the marker is at closest zoom.  Then have the option to reset which will smoothly zoom back out until all the markers are visable.

I managed to get it basically working by only doing any actions on the discrete change over point of the zoom.  Here are the relevant functions:

public void MoveToPosition (Vector2 posIn, int targetZoomIn) {
        fromPosition = OnlineMaps.instance.position;
        startZoom = OnlineMaps.instance.zoom;
        zoomIn = targetZoomIn > startZoom;
        time = timePerZoom * Mathf.Abs (targetZoomIn - startZoom);
        targetZoom = targetZoomIn;
        toPosition = posIn;
        angle = 0;
        isMovement = true;
    }

    void runMovement ()
    {
        angle += Time.deltaTime / time;

        if (angle > 1) {
            isMovement = false;
            OnlineMaps.instance.zoom = targetZoom;
            OnlineMaps.instance.SetPosition (toPosition.x, toPosition.y);
            return;
        }

        int currentZoom = Mathf.RoundToInt (Mathf.Lerp (startZoom, targetZoom, angle));


        if (OnlineMaps.instance.zoom != currentZoom) {
            if (zoomIn) {
                OnlineMapsControlBase.instance.ZoomOnPoint (currentZoom - OnlineMaps.instance.zoom, 
                OnlineMapsControlBase.instance.GetScreenPosition (toPosition));
                Vector2 CenterScreen = OnlineMapsControlBase.instance.GetCoords (new Vector2 (Screen.width / 2, Screen.height / 2));
                Vector2 pos = Vector2.Lerp (CenterScreen, toPosition, angle);
                OnlineMaps.instance.SetPosition (pos.x, pos.y);
            } else {
                int zoomsLeft = currentZoom - targetZoom;
                OnlineMapsControlBase.instance.ZoomOnPoint (currentZoom - OnlineMaps.instance.zoom, 
                OnlineMapsControlBase.instance.GetScreenPosition (fromPosition));
                Vector2 pos = Vector2.Lerp (fromPosition, toPosition, Mathf.Pow(0.5f,zoomsLeft));
                OnlineMaps.instance.SetPosition (pos.x, pos.y);
            }
        }
    }

    public void ZoomToCenterOfMarkers ()
    {
        Vector2 center;
        int zoom;
        OnlineMapsUtils.GetCenterPointAndZoom (OnlineMaps.instance.markers, out center, out zoom);
        MoveToPosition (center, zoom + 1); // Unsure why but the view is better at plus one zoom
    }

Do you have any advice on how to make this smoother?  I tried to adapt the smooth zoom feature (which I realise is designed for touch input) but it didn't perform well over large zoom amounts (starting with whole world and zooming in to a point of interest like the start of google earth).

Thanks

Re: Smooth-er zoom

Hello.

I will try to open the public access to the current version of Online Maps v3 on Monday.
It has a built-in true float zoom for all controls.
Follow the announcements in this section:
http://forum.infinity-code.com/viewforum.php?id=29

Kind Regards,
Infinity Code Team