1

Topic: Placing a marker in the sky at a specified altitude / GPS

I know... not a usual question.  But I'd like to place a prefab in the sky above the map (of course have it move with the map movement / zoom factor).  Here are my specific questions:

How do I place the object in the 3D space?  I have an AGL (above ground level) altitude in Meters, and GPS coordinates.  Do I send the lon/lat/alt to a function in your API?  If so, what is the function?  If not, do I use the place marker to get the lon/lat, and then use something else to get the alt of the ground below my desired location and add my AGL altitude?  If so, what format do I need to convert the meters to?  Will I need to update this conversion based on zoom level?

I know... complex question, but I'm stuck... I'm very much hoping I can just send WGS83 lon/lat and meter alt to your script and plug that response into a transform or something.  I was very hopeful when I saw the flying airplane in your demo video.  Seems like that is exactly what I'm trying to do.

Re: Placing a marker in the sky at a specified altitude / GPS

Hello.

The easiest way is to create 3D marker and set the altitude.
https://infinity-code.com/doxygen/onlin … 1b4998fa1e
https://infinity-code.com/atlas/online- … ample.html

To make the marker scale with the map instead of having a fixed size, set sizeType = OnlineMapsMarker3D.SizeType.realWorld and the desired scale value.
https://infinity-code.com/doxygen/onlin … 88ac04bdca
When sizeType - realWorld, the marker instance will have the specified scale at maximum zoom and will be halved every zoom level.
For example, with scale - 100, marker.instance.transform.localScale will be:
Zoom 20 - {100, 100, 100};
Zoom 19 - {50, 50, 50};
...
Zoom 15 - {3.125, 3.125, 3.125};
...
etc.

Kind Regards,
Infinity Code Team.

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

3

Re: Placing a marker in the sky at a specified altitude / GPS

Thank you.

So I added this script (using GPS coordinates that should mark the same location that I'm directly over), and set an altitude of 300 (not sure if that's meters, feet, etc).  But the result is that I end up with the marker at the corner of the map, and it doesn't move with the map when I move.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class placeMarker : MonoBehaviour
{
    /// <summary>
        /// Prefab of 3D marker
        /// </summary>
        public GameObject markerPrefab;

        private OnlineMapsMarker3D marker3D;

        /*private void OnGUI()
        {
            if (GUI.Button(new Rect(5, 5, 100, 20), "Move Left"))
            {
                // Change the marker coordinates.
                Vector2 mPos = marker3D.position;
                mPos.x += 0.1f;
                marker3D.position = mPos;
            }
        }*/

        private void Start()
        {
            // Get instance of OnlineMapsControlBase3D (Texture or Tileset)
            OnlineMapsControlBase3D control = OnlineMapsControlBase3D.instance;

            if (control == null)
            {
                Debug.LogError("You must use the 3D control (Texture or Tileset).");
                return;
            }

            // Marker position. Geographic coordinates.
            Vector2 markerPosition = new Vector2(30.341355816183523f,-97.91188041419034f);

            // Create 3D marker
            marker3D = OnlineMapsMarker3DManager.CreateItem(markerPosition, markerPrefab);
            marker3D.altitude = 300;
            // Specifies that marker should be shown only when zoom from 1 to 10.
            marker3D.range = new OnlineMapsRange(1, 20);
        }
    }

so it appears at the corner of the map, and very much below the map.

Re: Placing a marker in the sky at a specified altitude / GPS

Altitude in meters. This is specified in the API Reference.

The problem is that when you use Vector2, X is longitude, Y is latitude.
Latitude cannot be -97, so just reverse the order of the values.

P.S. When the marker needs to be visible at any zoom, you can simply remove the range setting line.

Kind Regards,
Infinity Code Team.

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

5

Re: Placing a marker in the sky at a specified altitude / GPS

Thank you again, Alex.  New issue though.  It appears that the altitude is sea level?  The altitude I have is AGL (above ground level).  Is there a method for getting the ground altitude at a GPS location so I can set the sea level altitude with some math?  currently my markers are appearing below the map when they are set at an altitude of 45 meters.  FYI, yes I am using a 3D map.

Re: Placing a marker in the sky at a specified altitude / GPS

marker3D.altitudeType = OnlineMapsAltitudeType.relative;
https://infinity-code.com/doxygen/onlin … 41dc6d3b33

Kind Regards,
Infinity Code Team.

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

7

Re: Placing a marker in the sky at a specified altitude / GPS

Thank you again for all your quick responses.  Hopefully this is the final question because I can now position, rotate, etc markers.  However, some of my other scripts are dependent on the name of the marker.  I saw that I can change the label.  But is there an actual way to change the name of the instanced marker as you would a GameObject.name="YadaYada"?  Marker3D.name does not seem to work.  If not, is there a way from the marker's start script to reference its label?  Again, apologies for my stupidity on this.

Re: Placing a marker in the sky at a specified altitude / GPS

You cannot do it directly.
But, you can add your own script to the marker prefab, which at Start will get OnlineMapsMarker3DInstance from this GameObject, and then get a reference to the marker from the instance.
https://infinity-code.com/doxygen/onlin … 83d582aa49

P.S. To store custom data (in this case, the passed GameObject name), it's better to use customFields instead of label, because the label will cause the tooltip to be displayed on hover.

Kind Regards,
Infinity Code Team.

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

9

Re: Placing a marker in the sky at a specified altitude / GPS

Thank you!  is there an example of using the OnlineMapsMarker3DInstance call inside the start of the marker instance?  I looked at the documentation, and I am a bit lost.

Re: Placing a marker in the sky at a specified altitude / GPS

public class SomeScript : MonoBehaviour
{
    private void Start()
    {
        OnlineMapsMarkerBase marker = GetComponent<OnlineMapsMarker3DInstance>().marker;
        gameObject.name = marker["name"] as string;

        // When you create a marker:
        // marker["name"] = "SOME NAME";
    }
}
Kind Regards,
Infinity Code Team.

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

11

Re: Placing a marker in the sky at a specified altitude / GPS

Fantastic!  I got that working, but I'm wondering if I'm using customFields correctly on the map instancing of the prefab script: 

marker3D.customFields['name']=droneList[keyValue.Key]["DroneName"];

Re: Placing a marker in the sky at a specified altitude / GPS

marker3D.customFields["name"] and marker3D["name"] are the same, but the second way is shorter.

Kind Regards,
Infinity Code Team.

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

13

Re: Placing a marker in the sky at a specified altitude / GPS

Thank you for all your help on this.  I have everything working now on this question.  I'm sure I'll have others later... but I am going to leave y'all a stellar review for your support on the asset store.

Re: Placing a marker in the sky at a specified altitude / GPS

Thank you. I really appreciate this.

Kind Regards,
Infinity Code Team.

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