1 (edited by habboazul3d 2021-10-25 20:51:29)

Topic: Aviation Maps using Unity

Hello, im new using Online Maps V3 and I've been trying to do something without success, so maybe if anyone can help me ill really appreciate it.

I need a simple 2D map with the capability to show in the screen a airplane icon, which must use a public variable of latitude and longitude given from another another script (lat/long public variable).
Also, the other script gives a heading number (between 0-360) which needs to be used to rotate the Map.

Ill attach a photo example of what i need. (Forget the map style, that's just a reference, i only need the classical open street style map).

I tried to use the Map Wizard but i don't know how to add a GameObject different of the Map Itself, and don't know how to handle markers etc.

This is something very very important because im working on my degree work, which i have to deliver in a few days.

THANK YOU!

Post's attachments

Attachment icon Screen Shot 2021-10-25 at 3.48.00 PM.png 176.26 kb, 48 downloads since 2021-10-25 

Re: Aviation Maps using Unity

Hello.

Use Online Maps Marker Manager component to create a 2D marker (in your case an airplane icon).
If it should be a 3D object, use Online Maps Marker 3D Manager component to create a 3D marker.

Next, use Online Maps API to update the marker position.

Examples of how to work with markers can be found in the atlas of examples.
https://infinity-code.com/atlas/online-maps/index.html

Kind Regards,
Infinity Code Team.

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

Re: Aviation Maps using Unity

Thank you, i now have the map and the marker working with the Location Service, but now i don't know how to change by code the latitude, longitude and compass heading.

I need to use a dynamic location coordinate from an external code, so i don't know how to change the Marker_GPS_Example to use the coordinates of my device.

Re: Aviation Maps using Unity

What programming experience do you have?
If you don't know how to program, use Playmaker or Bolt.
Online Maps has integration with these assets.
Maybe it will be easier for you.

Kind Regards,
Infinity Code Team.

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

Re: Aviation Maps using Unity

Ive working with C++ and Arduino for 2 years but C# is new to me.
I know that my requirements are very easy to do, but PlayMaker and Bolt are a different way to code, so i prefer to understand the code itself.

I just need to know the way to change the Marker_GPS_Example to use a vector like this Vector2(myLat, MyLon) to update its position, instead of using the Location Services.

That Vector2 is a dynamic vector, so it should update the map.

Re: Aviation Maps using Unity

OnlineMapsMarkerBase.SetPosition
https://infinity-code.com/doxygen/onlin … ac75c05eb0

Pay attention to two things:
1. This is not a static method and requires a marker instance.
Depending on how you created it, there are many ways to get it.
2. Online Maps API uses the order: in methods - first longitude, then latitude, in Vector2 - x is longitude, y is latitude.
I know that generally in geography latitude is used first.
But this contradicts another generally accepted rule - first the horizontal.
So we decided to use this order of parameters. In addition, this order is used in more than half of software mapping solutions.

Kind Regards,
Infinity Code Team.

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

Re: Aviation Maps using Unity

This is the code im trying to make to work, but ill put here the pseudo code about what i need.

public OnlineMapsMarker playerMarker;
        public float myLat;
        public float myLon;

        private void Start()
        {
            // Create a new marker.
            playerMarker = OnlineMapsMarkerManager.CreateItem(new Vector2(0, 0), null, "Airplane");

            // Get instance of LocationService.
            OnlineMapsLocationService locationService = OnlineMapsLocationService.instance;

            if (locationService == null)
            {
                Debug.LogError(
                    "Location Service not found.\nAdd Location Service Component (Component / Infinity Code / Online Maps / Plugins / Location Service).");
                return;
            }

            // myLat and myLon are the values i need to put on the position.

            // Subscribe to the change location event.
            locationService.OnLocationChanged += OnLocationChanged;
    
        }

        // When the location has changed
        private void OnLocationChanged(Vector2 position)
        {
            // Change the position of the marker.
            playerMarker.position = position;
            //playerMarker.position = (myLon,myLat);

            // Redraw map.
            OnlineMaps.instance.Redraw();
        }
    }

Re: Aviation Maps using Unity

What exactly is the problem you have with this script?

Kind Regards,
Infinity Code Team.

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

Re: Aviation Maps using Unity

The code is still using the Location Services to give the lat/lon coordinates and updates according to the change of it.
I need the same but using the lat/lon i give to the system manually and update the map according to that.

Re: Aviation Maps using Unity

If these are your coordinates, you don't need a Location Service.
You just create a marker using OnlineMapsMarkerManager.CreateItem and store it to the field.
When you need to update the position, you call marker.SetPosition and the map redraw (OnlineMaps.instance.Redraw).
https://infinity-code.com/doxygen/onlin … 4bb15e68ce
https://infinity-code.com/doxygen/onlin … ac75c05eb0
https://infinity-code.com/doxygen/onlin … 199d39b885

Kind Regards,
Infinity Code Team.

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