1 (edited by mikli1 2026-04-20 14:48:46)

Topic: Update markers position problem

Hi, I'm using Online maps 4.5.0.1 and Unity 6.3.
I have a custom markers engine just like in the examples. I'm calling UpdateMarkers when map moves (assigned to public Action OnMapUpdated). My application is only 2d. I'm using Canvas with screen overlay mode with canvas scaler - scale with screen size (mode expand). Also my map is in many places in my application and my map views have different sizes, sometimes full screen sometimes they are smaller in popups. In my setup I have a MapCamera that renders the map into a Map render texture. I have multiple RawImages in my project with RawImageTouchForwarders.

The problem I have is that when I move the map markers position is not updated with the same vector. They got desync and point to another location. Seems like something with the canvas scaler is incorrectly calculated... but I cannot find the error in the code.


This is my UpdateMarker method:

private void UpdateMarker(IUIEntity marker, MapController mc)
{
    if (marker == null || !marker.hasGameObject || marker.gameObject == null)
    {
        return;
    }

    Transform markerTransform = marker.gameObject.transform;
    RawImageTouchForwarder forwarder = markerTransform.parent.parent.GetComponentInChildren<RawImageTouchForwarder>(true);

    if (forwarder == null)
    {
        Logger.Error("Could not find raw image touch forwarder for marker: " + marker.gameObject.name);
        return;
    }

    Vector2 screenPosition = mc.control.LocationToScreen(marker.longitude, marker.latitude);
    screenPosition = forwarder.MapToForwarderSpace(screenPosition);

    RectTransformUtility.ScreenPointToLocalPointInRectangle(markerTransform.parent as RectTransform, screenPosition, null, out Vector2 point);
    markerTransform.localPosition = point;
}

Thanks for help.

Re: Update markers position problem

Hi,

I’ve taken a look, but I don’t see any obvious issues that would clearly explain the problem.
At least nothing that stands out right away.
If you’d like, you can send me a minimal project where the issue is reproducible.
That would make it much easier to debug and understand what’s going on.
You can send it to me by email or via Discord.

Kind Regards,
Infinity Code Team.

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

Re: Update markers position problem

Hey, I've sent you an email with the project. Thank you.