Topic: Get world Y position from real elevation

Hello, I should place some objects at their real height (not on the top of the map mesh, that can be not so much reliable).
So, I would'nt care if they them don't touch the map.
I know their real elevation, but looking at OnlineMaps api I can't find a function to get the world Y position from elevation (maybe I didn't look so well...).
Which could be the best approach to do this?
Many thanks!

Re: Get world Y position from real elevation

Hello.

Unfortunately, I did not understand your question.

Most likely you are looking for something from this:
OnlineMapsMarker3D.altitude
http://infinity-code.com/doxygen/online … 5cd33d18f5
OnlineMapsElevationManagerBase.GetElevation
http://infinity-code.com/doxygen/online … a7c3d53b97
OnlineMapsControlBaseDynamicMesh.GetWorldPositionWithElevation
http://infinity-code.com/doxygen/online … aeedf61eb0

Or is it from your topic:
http://forum.infinity-code.com/viewtopi … 4824#p4824

If you are looking for something else, please rephrase your question.

Kind Regards,
Infinity Code Team.

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

Re: Get world Y position from real elevation

Thank-you for your reply,
I'll try to rephrase:
I think that OnlineMapsElevationManagerBase.GetElevation use the longitude-latitude of a point to retrieve its elevation from the loaded map (but maybe I'm wrong).
Let's say that I'd like to place a plane over the map, and I know that the plane is flying at the altitude of 350 meters.
I don't care about its longitude-latitude, and I don't care about the underlying map 3d model, because the elevation accuracy of the map 3d model change on the basis of the zoom (the more is zoomed, the more the altitude is accurate, at least with bing, mapbox, etc, from what I can see).
So, maybe my underlying map is not so accurate, but I'd like to place my plane at its real height.
It should be easy to place my plane at 350m if the altitude of the map 3d model was the real one in world space, but the lowest elevation of the map is always at 0 (with BottomMode = minValue).
I hope I explained myself better.

Re: Get world Y position from real elevation

Something like that?

using System;
using UnityEngine;

public class GetWorldPositionWithElevation : MonoBehaviour
{
    public GameObject target;
    public float altitude;
    private float _altitude;

    private void Start()
    {
        OnlineMaps.instance.OnChangePosition += UpdatePositionY;
        OnlineMaps.instance.OnChangeZoom += UpdatePositionY;

        UpdatePositionY();
    }

    private void Update()
    {
        if (Math.Abs(_altitude - altitude) > float.Epsilon) UpdatePositionY();
    }

    private void UpdatePositionY()
    {
        _altitude = altitude;

        if (!OnlineMapsElevationManagerBase.isActive) return;

        Vector3 pos = target.transform.position;
        float v = altitude;
        if (OnlineMapsElevationManagerBase.instance.bottomMode == OnlineMapsElevationBottomMode.minValue) v -= OnlineMapsElevationManagerBase.instance.minValue;
        pos.y = OnlineMapsElevationManagerBase.GetBestElevationYScale() * v;
        target.transform.position = pos;
    }
}
Kind Regards,
Infinity Code Team.

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

Re: Get world Y position from real elevation

You are my hero!
5 stars for your asset, and 6 stars for your support!
Many thanks