Topic: zoom and CameraUpdate

Good evening.
I need to limit the radius of the map. I inserted my code into your scripts. Now I fix bugs, but it's too difficult, I kind of did everything you need, but it does not work.


It is necessary that the phone has a smooth zoom between 12-19 zoom to the limit of 12 did not go this smooth zoom. Really?

If the scale is < 15, you must set the center of the map to the center of the user around which the radius is. You can only move around the map when you zoom in > 15 and only to the radius boundaries.

The problem is that I don't understand how to limit the smooth scaling to not < 12.
Also, you cannot force the map to set its position during scaling. When I do the fingers the zoom is less than 15, the map should be centered in the user, but this is not happening and position of the card outside of the radius, probably because the method is "UpdateGestureZoom" and "CameraUpdatePosition" do not work at the same time, called "CameraUpdatePosition" in "UpdateGestureZoom" did not give an adequate result.

Please tell me how you can correctly enter it into your plugin?

    public bool SetPositionCameraByCircleBorder(double px, double py) {
        Vector2 p1 = this.GetPositionPlayerInMeters();
        Vector2 p2 = this.GetPositionMapInMeters((float)px, (float)py);
        float angle = OnlineMapsUtils.Angle2D(p1, p2);
        angle += 90;
        float distance = OnlineMapsUtils.DistanceBetweenPointsF(
            new Vector2(this.posUser.x, this.posUser.y),
            new Vector2((float)px, (float)py)
        );


        float radius = MyCode.JourneyObject.instance.drawRadiusMapForFog.radiusInKM;
        if (radius < distance) {
            OnlineMapsUtils.GetCoordinateInDistance(
                this.posUser.x, this.posUser.y,
                radius,
                angle,
                out double nlon, out double nlat
            );
            map.SetPosition(nlon, nlat);
            return true;
        }
        return false;
    }

Re: zoom and CameraUpdate

Hello.

The problem is that I don't understand how to limit the smooth scaling to not < 12.

Use this example, and add an additional check before line 51:
http://infinity-code.com/atlas/online-m … ample.html

else if (OnlineMaps.instance.zoom <= 12 && t.localScale.x < 1)
{
  OnlineMaps.instance.zoom = 12;
  t.localScale = Vector3.one;
}

Also, you cannot force the map to set its position during scaling.

Why not?

Perhaps you mean that smooth zoom can happen not at the center point. But in this case you can use Zoom Mode - Center.

In general, it is better to use Online Maps v3 beta for smooth zoom.
It has a built-in float zoom, and perhaps (most likely) is much better suited for your purposes.

Kind Regards,
Infinity Code Team.

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

3 (edited by NovaEiz 2018-09-27 12:34:29)

Re: zoom and CameraUpdate

Thanks for the help)

Tell me how to turn off the rotation of the map with two fingers for the phone. I have covered all the code and have not found this place. That's how I made a rotation around the center for the editor. And for the phone, you need to turn off the rotation with your finger to rotate only from the compass.

protected void UpdateCameraPosition()
    {
        if (cameraRotation.x > maxCameraRotationX) cameraRotation.x = maxCameraRotationX;
        else if (cameraRotation.x < 0) cameraRotation.x = 0;

        cameraRotation.x = MyCode.MapController.instance.cameraRotationX;
#if UNITY_EDITOR
        if (Input.GetMouseButtonDown(1)) {
            this.isBeginRotateCamera = true;
        }
        if (Input.GetMouseButton(1)) {
            cameraRotation.y = GetAngleCameraFromCenterScreenByMousePosition();
        }
#endif

        float rx = 90 - cameraRotation.x;
        if (rx > 89.9) rx = 89.9f;

        double px = Math.Cos(rx * Mathf.Deg2Rad) * cameraDistance;
        double py = Math.Sin(rx * Mathf.Deg2Rad) * cameraDistance;
        double pz = Math.Cos(cameraRotation.y * Mathf.Deg2Rad) * px;
        px = Math.Sin(cameraRotation.y * Mathf.Deg2Rad) * px;

        Vector3 targetPosition = transform.position;
        if (this is OnlineMapsTileSetControl)
        {
            Vector3 offset = new Vector3(map.tilesetSize.x / -2, 0, map.tilesetSize.y / 2);
            OnlineMapsTileSetControl control = OnlineMapsTileSetControl.instance;

            if (control.smoothZoom && control.smoothZoomStarted) targetPosition = originalPosition;
            
            if (control.useElevation && control.elevationZoomRange.InRange(map.zoom))
            {
                double tlx, tly, brx, bry;
                map.GetCorners(out tlx, out tly, out brx, out bry);
                float yScale = control.GetBestElevationYScale(tlx, tly, brx, bry);
                if (cameraAdjustTo == OnlineMapsCameraAdjust.maxElevationInArea) offset.y = control.GetMaxElevationValue(yScale);
                else offset.y = control.GetElevationValue(targetPosition.x, targetPosition.z, yScale, tlx, tly, brx, bry);
            }
            
            offset.Scale(control.smoothZoomStarted? control.originalScale: transform.lossyScale);
            targetPosition += transform.rotation * offset;
        }

        Vector3 oldPosition = activeCamera.transform.position;
        Vector3 newPosition = transform.rotation * new Vector3((float)px, (float)py, (float)pz) + targetPosition;

        activeCamera.transform.position = newPosition;
        activeCamera.transform.LookAt(targetPosition);

        if (oldPosition != newPosition && OnCameraControl != null) OnCameraControl();
    }

Re: zoom and CameraUpdate

And another question.
How can I disable moving the map with two fingers during a smooth zoom on my phone?

Re: zoom and CameraUpdate

Use the compilation directives to enable or disable part of the code for a specific platform.
https://docs.unity3d.com/Manual/Platfor … ation.html

In OnlineMapsTileSetControl.OnSmoothZoomBegin, save the coordinates of the map.
In OnlineMapsTileSetControl.OnSmoothZoomProcess, restore the coordinates of the map.

Kind Regards,
Infinity Code Team.

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

Re: zoom and CameraUpdate

Thank you!
Please answer, please, not the previous question about the turn.

Re: zoom and CameraUpdate

Did I miss something?

The first two lines, this is the answer to the post 3.
The second two lines, this is the answer to the post 4.

Kind Regards,
Infinity Code Team.

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

Re: zoom and CameraUpdate

You see. I have disabled all parts of the code where the value cameraRotation.y is assigned. But the camera still rotates. Checked on the Nox emulator. I can not yet from the phone, but it's strange if the phone is different

Re: zoom and CameraUpdate

Vanga mode - ON:
you have disabled not all the parts of the code.

Look in OnlineMapsControlBase3D.AfterUpdate and OnlineMapsControlBase3D.OnGestureZoom.

But the easiest way to turn off rotation is to set cameraSpeed = new Vector2 (1, 0).

Kind Regards,
Infinity Code Team.

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

Re: zoom and CameraUpdate

Alex Vertax wrote:

Vanga mode - ON:

Sorry. It's not my English so rude, the translator Google is so stupid (

Re: zoom and CameraUpdate

I'm sorry, I did not want to confuse you.
Vanga - is a Bulgarian prophetess.
https://en.wikipedia.org/wiki/Baba_Vanga

"Vanga mode - ON" means "My prediction".

Kind Regards,
Infinity Code Team.

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

Re: zoom and CameraUpdate

Alex Vertax wrote:

I'm sorry, I did not want to confuse you.
Vanga - is a Bulgarian prophetess.
https://en.wikipedia.org/wiki/Baba_Vanga

"Vanga mode - ON" means "My prediction".

I know what that means.) Just apologized for the translation, Google translates poorly. He's kind of a rude translator, and often wrong.