Topic: Rotate the camera by compass when online map is sprite render.

Is it possible to rotate the camera by the compass when I use sprite render for map and my own system for markers? I was tried to do it, but markers showing in wrong places when I rotate the camera.

Re: Rotate the camera by compass when online map is sprite render.

Hello.

The problem is fixed.
The new version will be available through the built-in update system within two days.

Kind Regards,
Infinity Code Team.

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

Re: Rotate the camera by compass when online map is sprite render.

Great!!! Thanks! Waiting for update.

Re: Rotate the camera by compass when online map is sprite render.

Thanks for plugin update! But it looks like OnlineMapsControlBase.instance.GetScreenPosition function gives me wrong data now. I use it for calculation markers coordinates in world space.

Re: Rotate the camera by compass when online map is sprite render.

I made a simple script, and it works correctly for me.
Please check your script. Maybe it works incorrectly, because in the old version of Online Maps this method did not work correctly?!

Script:

using UnityEngine;

public class LogCoordinatesUnderCursor:MonoBehaviour
{
    private void OnGUI()
    {
        Vector2 coords = OnlineMapsControlBase.instance.GetCoords();

        GUIStyle style = new GUIStyle(GUI.skin.label);
        style.fontSize = 24;
        style.normal.textColor = Color.red;

        GUILayout.Label("Top Left: " + OnlineMaps.instance.topLeftPosition.ToString("F6"), style);
        GUILayout.Label("Bottom Right: " + OnlineMaps.instance.bottomRightPosition.ToString("F6"), style);
        GUILayout.Label("Coords: " + coords.ToString("F6"), style);
        GUILayout.Label("Input: " + OnlineMapsControlBase.instance.GetInputPosition(), style);
        GUILayout.Label("Screen Position: " + OnlineMapsControlBase.instance.GetScreenPosition(coords), style);
    }
}
Kind Regards,
Infinity Code Team.

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

Re: Rotate the camera by compass when online map is sprite render.

The problem was in that I should remake texture for the map and started work correctly. But now I have a new problem. When markers are behind the screen this function gives me wrong coordinates. I have to draw a polygon on this markers, so when I drag the map and markers change coordinates into the wrong, the polygon has wrong sides.

Re: Rotate the camera by compass when online map is sprite render.

We have slightly improved this method.
Now this should work better for you.
The next version will contain this.

OnlineMapsSpriteRendererControl.GetScreenPosition:

public override Vector2 GetScreenPosition(double lng, double lat)
{
    double tlx, tly, brx, bry;
    map.GetTileCorners(out tlx, out tly, out brx, out bry);
    int maxX = 1 << map.zoom;
    if (tlx > brx) brx += maxX;

    double px, py;
    map.projection.CoordinatesToTile(lng, lat, map.zoom, out px, out py);

    if (px + maxX / 2 < tlx) px += maxX;

    double rx = (px - tlx) / (brx - tlx) - 0.5;
    double ry = 0.5 - (py - tly) / (bry - tly);

    Bounds bounds = spriteRenderer.sprite.bounds;
    Vector3 size = bounds.size;

    rx *= size.x;
    ry *= size.y;

    Vector3 worldPoint = transform.localToWorldMatrix.MultiplyPoint(new Vector3((float)rx, (float)ry, bounds.center.z));
    return Camera.main.WorldToScreenPoint(worldPoint);
}
Kind Regards,
Infinity Code Team.

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

Re: Rotate the camera by compass when online map is sprite render.

Great!!! Thank you!!!