Topic: Camara Orbit Tremling

hi
i used Orbit Camera when i move with my device the map tremling .
i will include a video and some screen shots about my code and live video about tremling map and olso a screen shot about map settings.
and i whant after correct the problem to have the RED arrow marker to stacked and  stay look to front whithout rotating with the map when compas change .

Video Link:
https://www.loom.com/share/9bc595d817bc … 21e8210523

My Script:

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


public class MapManager : MonoBehaviour
{
    public OnlineMaps map;
    public GameObject startMarkerPrefab;
    public GameObject destinationMarkerPrefab;
    //public string googleAPIKey; // Your Google API Key
    private string googleAPIKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
    private OnlineMapsMarker startMarker;
    private OnlineMapsMarker destinationMarker;
    private Vector2 currentLocation;
    private Vector2 destinationLocation;
    private bool routePlotted;
    public Text debug;
    private float updateInterval = 1f; // How often to update the marker position
    private float updateTimer; // Timer to manage update intervals

    public GameObject StartHandlr, RoomHandlr, GPSHandlr;
    //public OnlineMapsControlBase3D control;
    public OnlineMapsCameraOrbit cameraOrbit;
    public Transform TcameraOrbit;
    public Texture2D MarkerS, MarkerD;
    float latitude, longitude;
    OnlineMapsLocationServiceBase locationService;

    public int speed = 10;


    private float targetAngle;
    private bool lerpTargetAngle;
    private Vector2 lastRotation;

    private void Start()
    {
        if (string.IsNullOrEmpty(googleAPIKey))
        {
            Debug.LogWarning("Please specify your Google API Key.");
            return;
        }

        if (map == null) map = OnlineMaps.instance;

        if (cameraOrbit == null) cameraOrbit = OnlineMapsCameraOrbit.instance;

        //locationService.OnLocationChanged += OnLocationChanged;
        //locationService.OnCompassChanged += OnCompassChanged;
        //debug.text = "Start Function";
        locationService = OnlineMapsLocationService.instance;
        StartCoroutine(StartLocationService());
        // OnlineMapsLocationServiceBase.OnLocationInited


        //locationService.OnLocationChanged += OnLocationChanged;
        //locationService.OnCompassChanged += OnCompassChanged;
        //locationService.desiredAccuracy = 10; // Meters. Lower means more accuracy.
        //locationService.updateDistance = 5; // Meters. This sets how far you must move before an update is triggered.
        //the rotation is kind of glitchy
    }

    private IEnumerator StartLocationService()
    {
        //debug.text = "Start Location Service.";
        Input.location.Start();
        while (Input.location.status == LocationServiceStatus.Initializing)
        {
            yield return new WaitForSeconds(1);
        }
        if (locationService != null)
        {
            // Subscribe to the OnLocationChanged and OnCompassChanged events
            locationService.OnLocationChanged += OnLocationChanged;
            locationService.OnCompassChanged += OnCompassChanged;
            lastRotation = cameraOrbit.rotation;
            targetAngle = lastRotation.y;

            // Enable the location service if it's not already enabled
            if (!locationService.isActiveAndEnabled)
            {
                locationService.SetStarted(true);
                debug.text = "locationService Start.";
            }
        }
        else
        {
            Debug.LogError("OnlineMapsLocationService instance is null. Make sure it's added to your scene.");
        }
        if (Input.location.status == LocationServiceStatus.Running)
        {
            //debug.text = "Location services are enabled and running";
            // Get the current location
            currentLocation = new Vector2(Input.location.lastData.longitude, Input.location.lastData.latitude);
            //debug.text = "Location services are  running.";
            PlaceStartMarker(currentLocation);
        }
        else
        {
            Debug.LogError("Location services are disabled or not running.");
            //debug.text = "Location services are disabled or not running.";
        }
    }

    public void SearchAndPlotRoute(string address)
    {
        if (!string.IsNullOrEmpty(address))
        {
            OnlineMapsGoogleGeocoding geocoding = new OnlineMapsGoogleGeocoding(address, googleAPIKey);
            geocoding.OnComplete += OnGeocodingComplete;
            geocoding.Send();
        }
        else
        {
            Debug.LogError("Address input is empty.");
        }
    }

    private void OnGeocodingComplete(string result)
    {
        Vector2 position = OnlineMapsGoogleGeocoding.GetCoordinatesFromResult(result);

        if (position != Vector2.zero)
        {
            destinationLocation = position;
            PlaceDestinationMarker(destinationLocation);

            // Once destination is set, plot the route.
            StartCoroutine(GetRoute(currentLocation, destinationLocation));
        }
        else
        {
            Debug.LogError("Failed to find the location.");
        }
    }

    private void PlaceStartMarker(Vector2 location)
    {
        if (startMarker == null)
        {
            startMarker = OnlineMapsMarkerManager.CreateItem(location,MarkerS, "Start Marker");
            //startMarker.texture = MarkerS;
            startMarker.scale = 0.03f;
            //startMarker.Init();
            //debug.text="Place Start Markern.";
        }
        else
        {
            startMarker.position = location;
        }

        map.SetPositionAndZoom(location.x, location.y, 16);

    }

    private void PlaceDestinationMarker(Vector2 location)
    {
        if (destinationMarker == null)
        {
            destinationMarker = map.markerManager.Create(location,MarkerD, "Destination Marker");
            //destinationMarker.texture = MarkerD;
            destinationMarker.scale = 0.03f;
            //destinationMarker.Init();
            //debug.text = "Place Destinatio nMarker.";
        }
        else
        {
            destinationMarker.position = location;
        }
    }

    private IEnumerator GetRoute(Vector2 start, Vector2 end)
    {
        OnlineMapsGoogleDirections request = new OnlineMapsGoogleDirections(googleAPIKey, start, end);
        request.OnComplete += OnRouteComplete;
        yield return null;
    }

    private void OnRouteComplete(string result)
    {
        //Debug.Log(response);

        OnlineMapsOpenRouteServiceDirectionResult result1 = OnlineMapsOpenRouteServiceDirections.GetResults(result);
        if (result == null || result1.routes.Length == 0)
        {
            Debug.Log("Open Route Service Directions failed.");
            return;
        }

        // Get the points of the first route.
        List<OnlineMapsVector2d> points = result1.routes[0].points;

        // Draw the route.
        OnlineMapsDrawingLine line = new OnlineMapsDrawingLine(points, Color.red);
        map.drawingElementManager.Add(line);

        // Set the map position to the first point of route.
        map.position = points[0];
        StartCoroutine(MoveMarkerAlongRoute(points));
    }

    private IEnumerator MoveMarkerAlongRoute(List<OnlineMapsVector2d> points)
    {
        foreach (Vector2 point in points)
        {
            startMarker.position = point;
            yield return new WaitForSeconds(0.1f); // Simulate movement
        }
    }
    public void ReturnToRoom()
    {
        GPSHandlr.SetActive(false);
        float leftMargin = 0f;  // Adjust the left margin
       float rightMargin = 0f; // Adjust the right margin
       RectTransform rectTransform = RoomHandlr.GetComponent<RectTransform>();
       rectTransform.offsetMin = new Vector2(leftMargin, rectTransform.offsetMin.y);
       rectTransform.offsetMax = new Vector2(-rightMargin, rectTransform.offsetMax.y);

        rectTransform = StartHandlr.GetComponent<RectTransform>();
        rectTransform.offsetMin = new Vector2(leftMargin, rectTransform.offsetMin.y);
        rectTransform.offsetMax = new Vector2(-rightMargin, rectTransform.offsetMax.y);

       
    }
   

    private void OnDisable()
    {
        // Stop the location service when the script is disabled
        Input.location.Stop();
    }
   

    private void OnCompassChanged(float f)
    {
        cameraOrbit.rotation.y = f * 360;
        //targetAngle = f * 360;
        //float angle = cameraOrbit.rotation.y;
        //if (angle - targetAngle > 180) targetAngle -= 360;
        //else if (targetAngle - angle > 180) targetAngle += 360;

        //lerpTargetAngle = true;
    }
   
    //This event occurs at each change of GPS coordinates
    private void OnLocationChanged(Vector2 position)
    {
        //Change the position of the marker to GPS coordinates
        startMarker.position = position;
        //debug.text = "On Location Changed.";
        map.Redraw();
    }
    void Update()
    {
        // Disable two-finger gestures by checking touch count
        if (Input.touchCount > 1)
        {
            // Prevent any two-finger interaction with the map
            return;
        }
        if (lastRotation != cameraOrbit.rotation) lerpTargetAngle = false;

        if (lerpTargetAngle)
        {
            float newAngle = Mathf.Lerp(lastRotation.y, targetAngle, Time.deltaTime * speed);
            if (Mathf.Abs(newAngle - lastRotation.y) < 0.1)
            {
                lerpTargetAngle = false;
                cameraOrbit.rotation.y = targetAngle;
            }
            else cameraOrbit.rotation.y = newAngle;

            lastRotation = cameraOrbit.rotation;
        }
    }
   
}

Post's attachments

Attachment icon 1.png 48.77 kb, 215 downloads since 2024-10-27 

2 (edited by tamim.ali.zoabi 2024-10-27 17:42:06)

Re: Camara Orbit Tremling

I don't know how to attach more than 1 picture so I'll add the other in the Replay

Post's attachments

Attachment icon 2.png 50 kb, 190 downloads since 2024-10-27 

Re: Camara Orbit Tremling

more pictures

Post's attachments

Attachment icon 3.png 42.69 kb, 207 downloads since 2024-10-27 

Re: Camara Orbit Tremling

more pictures

Post's attachments

Attachment icon 4.png 51.68 kb, 200 downloads since 2024-10-27 

Re: Camara Orbit Tremling

Hi.

1. You have Camera Orbit / Compass Threshold - 8, and because of this the camera rotates in 8 degree increments.
2. You have a block commented out in your script that smooths out the camera rotation, so the rotation is immediate.

An example of how to smooth camera rotation is attached.
Before using it, please do not forget to disable camera interaction in your scripts.

Post's attachments

Attachment icon SmoothCameraByCompass.cs 1.32 kb, 239 downloads since 2024-10-28 

Kind Regards,
Infinity Code Team.

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

6 (edited by tamim.ali.zoabi 2024-10-28 22:02:16)

Re: Camara Orbit Tremling

how to prevent marker to be rotate while map rotated and make marker stacked in the bottom of the map without rotate in any situation ?

Re: Camara Orbit Tremling

This script only rotates the camera, not the markers.
So you don't need to do anything for that.

An example of how to make a marker to be at the bottom is attached.

Post's attachments

Attachment icon MarkerAtBottom.cs 740 b, 208 downloads since 2024-10-29 

Kind Regards,
Infinity Code Team.

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

Re: Camara Orbit Tremling

i used MarkerAtBottom.cs but i got many strange outputs.
then i have my code like that:
using UnityEngine;
using UnityEngine.UI;

public class MarkerAtBottom : MonoBehaviour
{
    public OnlineMapsControlBase3D control;
    public float zoomLevel = 14;
    public GameObject prefab;
    private Vector2 currentLocation;
    private OnlineMapsMarker3D locationMarker;
    public float distance = 1;
    public Text text;

    private void Start()
    {
        // If the control is not specified, get the current instance.
        if (control == null) control = OnlineMapsControlBase3D.instance;

        // Check if the control is 3D.
        if (control == null)
        {
            text.text = "You must use the 3D control (Texture or Tileset).";
            return;
        }

        // Get initial location
        currentLocation = new Vector2(Input.location.lastData.longitude, Input.location.lastData.latitude);
        SetMapPositionWithOffset(currentLocation, 0.3f);
        // Create marker at an initial position
        locationMarker = control.marker3DManager.Create(Vector2.zero, prefab);
        locationMarker.scale = 6f;
        locationMarker.enabled = false;

       
        // Center map on initial location and set zoom
        OnlineMaps.instance.SetPositionAndZoom(currentLocation.x, currentLocation.y, zoomLevel);

        // Set up location service and subscribe to events
        OnlineMapsLocationService ls = OnlineMapsLocationService.instance;
        if (ls == null)
        {
            text.text = "Location Service not found.";
            return;
        }

        // Subscribe to GPS location changes
        ls.OnLocationChanged += OnLocationChanged;
    }
    private void Update()
    {
        // Lock the rotation of the marker prefab
        if (locationMarker != null && locationMarker.instance != null)
        {
            locationMarker.instance.transform.rotation = Quaternion.identity;
        }
    }
    private void OnLocationChanged(Vector2 position)
    {
        // Update marker position when GPS location changes
        if (locationMarker != null)
        {
            locationMarker.position = position;
            locationMarker.enabled = true;

            // Optionally, recenter map on the new position
            //OnlineMaps.instance.position = position;
            //SetMapPositionWithOffset(position, 0.2f);
        }
    }
    private void SetMapPositionWithOffset(Vector2 position, float offset)
    {
        // Calculate a latitude offset for the map (positive moves it up, negative moves it down)
        double offsetLatitude = position.y + offset;

        // Set the map's center position with the adjusted latitude and specified zoom level.
        OnlineMaps.instance.SetPositionAndZoom(position.x, offsetLatitude, zoomLevel);
    }
}
but the map still centered, and the Marker still rotate when map rotated. what i should change or add to my script to have the map set slightly to bottom and marker appear slightly at bottom and not rotated.

Re: Camara Orbit Tremling

In this script you are not rotating the marker, so this behavior is coming from some other script you are using.
Most likely the rotating marker is a different marker than the one you are creating in this script.
So please check the scripts you are using.

Kind Regards,
Infinity Code Team.

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

10 (edited by tamim.ali.zoabi 2024-10-31 18:40:20)

Re: Camara Orbit Tremling

were did i used a different marker in the script . i create a 3d mareker prefab (locationMarker) and i used it in the script,
i was trying to search for another marker as you say , cant find were is the point that you trying to explain to me.

beside that there is a strange rotation problem , when i start driving the Direction is correct as a compas direction . suddenly it start to be inverted and for while the marker go out of the road "1 cm" .
is there any adjustments i should setup in map scripts . or what is the reason for that mostly .

Re: Camara Orbit Tremling

OK. I don't believe in magic, and there is a reasonable explanation for everything.

You have a situation where the marker rotates with the map.
Let's look at all the cases where this is possible:
1. You are rotating in this script.
Not in this case, because you are not rotating in this script.
2. Another script takes the marker on the link and rotates it.
Not in this case, because the field is private.
3. Another script gets the marker using reflection.
I am 100% sure you are not doing that.
4. Another script takes that marker from Marker 3D Manager and rotates it.
Maybe, but very unlikely.
5. A script on the marker itself rotates it.
Maybe, but unlikely.
6. You have multiple markers that multiple scripts create, and it is not the marker created by this script that is rotated, but another marker created by another script.
This is the most likely scenario, and is very easy to check just by looking in the inspector on the Marker 3D Manager.

Unfortunately, I didn't understand the “strange rotation problem”.
I think a short video showing the problem would help a lot to explain it.

Kind Regards,
Infinity Code Team.

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

Re: Camara Orbit Tremling

When i set my device in lying flat on a table, compass readings compas result, but when tilted in same direction , giving me another reading "the map rotate using other degrees from lying flat" .
in my code i used just Y axis . how can i just read Y axis .
My Code:
public OnlineMapsControlBase3D control;
    public GameObject prefab;
    private OnlineMapsMarker3D locationMarker;
    private OnlineMaps map;
    public float duration = 1;
    public float compassThreshold = 4;

    private float progress = 1;
    private float fromHeading;
    private float toHeading;

    public OnlineMapsCameraOrbit cameraOrbit;
    private OnlineMapsMarker playerMarker;
    public GameObject StartHandler, RoomHandler, GpsHandler;

 
   

    private void Start()
    {
        if (map == null) map = OnlineMaps.instance;
        playerMarker = map.markerManager.Create(0, 0, null, "Player");
        playerMarker.scale = 0.018f;
       
        if (cameraOrbit == null) cameraOrbit = OnlineMapsCameraOrbit.instance;
        OnlineMapsLocationService locationService = OnlineMapsLocationService.instance;
        locationService.compassThreshold = 0;
        if (locationService == null)
        {
            Debug.LogError(
                "Location Service not found.\nAdd Location Service Component (Component / Infinity Code / Online Maps / Plugins / Location Service).");
            return;
        }
        locationService.OnLocationChanged += OnLocationChanged;
        OnlineMapsLocationService.instance.OnCompassChanged += OnCompassChanged;
       
    }
 
    private void OnLocationChanged(Vector2 position)
    {
        playerMarker.position = position;
        map.Redraw();
    }
    private void OnCompassChanged(float heading)
    {
        heading *= 360;
        if (Mathf.Abs(heading - toHeading) < compassThreshold) return;

        toHeading = heading;
        fromHeading = cameraOrbit.rotation.y;
        progress = 0;
        playerMarker.rotation= (heading * 360)/360;
    }
    private void Update()
    {
        if (progress >= 1) return;

        progress += Time.deltaTime / duration;
        cameraOrbit.rotation.y = Mathf.LerpAngle(fromHeading, toHeading, progress);
    }

Re: Camara Orbit Tremling

It's a compass, not a gyroscope, and it has no axis rotation. Only the direction to the north pole.

Online Maps Location Service is just a wrapper for Unity Location Service and Unity Compass classes.
If you want you can access Unity Compass directly.

Kind Regards,
Infinity Code Team.

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

Re: Camara Orbit Tremling

what does thats mean ?
were is the problem ?
can you please expleane it to me ?

Re: Camara Orbit Tremling

how can i just read Y axis .

You can't get only Y axis because it's a compass.
Online Maps Location Service takes values from the Unity Compass class and if it has changed passes it to you.
I don't know why you have different compass values for different device tilts.

Kind Regards,
Infinity Code Team.

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

Re: Camara Orbit Tremling

i ll record a video to show you the problem when i hold my device vertically it show streets in a certain situation, but when i change holding the devise i same direction but in horizontal position the map direction change some degrees "20-40 degrees" !!!!!!

Re: Camara Orbit Tremling

Here is a video
I don't change direction just changed holding vertically an horizontally. But it change the map rotation at the time I didn't change direction

Video link :
https://www.loom.com/share/ec479ae61043 … 31d4818c87

Re: Camara Orbit Tremling

Your camera changes by 20-40 degrees because that data comes from Unity Compass.
https://docs.unity3d.com/ScriptReference/Compass.html
Unfortunately, I don't know why there is such a change in your case.
You'd better ask Unity support.

Kind Regards,
Infinity Code Team.

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

19 (edited by tamim.ali.zoabi 2024-11-04 12:29:13)

Re: Camara Orbit Tremling

Alex Vertax wrote:

Your camera changes by 20-40 degrees because that data comes from Unity Compass.
https://docs.unity3d.com/ScriptReference/Compass.html
Unfortunately, I don't know why there is such a change in your case.
You'd better ask Unity support.

1-so generaly it must be stabile ؟ how cani make camera   data comes from online maps V3 Compass ?
can you give me any very simple example about using compass and orbitCam and any settings if needed . to find were is the problem . i think this problem not supposed to be "Error of rotation by compass" !!!

2-maybe i did not understood ... is there a compass for unity and compass for online maps3 v3 . and i uses a deferent one ????

3- if you look at the attached image , you can see the rout drawn out of the roads !!!!!!

Post's attachments

Attachment icon Map2.jpg 63.32 kb, 230 downloads since 2024-11-04 

Re: Camara Orbit Tremling

1, 2. There's one compass here, and it's Unity Compass.
Online Maps takes data from it, and notifies the user when the value has changed. No more, no less.
So, unfortunately, I can't help with your device tilt problem, and you need to contact Unity support.

3. Where did you get the points of the route from?
If it is some script, please show it.
If it's your data, check it on any other map, like the web version of Google Maps.

Kind Regards,
Infinity Code Team.

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

Re: Camara Orbit Tremling

/*         INFINITY CODE         */
/*   https://infinity-code.com   */

using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

namespace InfinityCode.OnlineMapsDemos
{
    [AddComponentMenu("Infinity Code/Online Maps/Demos/Search Panel")]
    public class SearchPanel:MonoBehaviour
    {
        public GameObject MapHald;
        private Button itemButton;
        private Transform firstItem;
        public string googleAPIKey= "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
        /// <summary>
        /// (Optional) Reference to the map. If not specified, the current instance will be used.
        /// </summary>
        public OnlineMaps map;
        public GameObject scrollViewSearchHandlr;
        /// <summary>
        /// Reference to the input field.
        /// </summary>
        public InputField inputField;
       
        /// <summary>
        /// Indicates whether to use autocomplete.
        /// </summary>
        public bool useAutocomplete = false;
       
        /// <summary>
        /// Reference to the autocomplete container.
        /// </summary>
        public RectTransform autocompleteContainer;
       
        /// <summary>
        /// Reference to the autocomplete item prefab.
        /// </summary>
        public GameObject autocompleteItemPrefab;
       
        /// <summary>
        /// Marker that shows the search result on the map.
        /// </summary>
        private OnlineMapsMarker marker;
        private OnlineMapsGoogleGeocodingResult[] LatteryResults;
        public int Index_Result_Selected=-1;
        /// <summary>
        /// Hides the autocomplete container if the mouse is not over it.
        /// </summary>
        private void HideAutocomplete()
        {
            if (!useAutocomplete) return;
            if (autocompleteContainer == null) return;
            if (RectTransformUtility.RectangleContainsScreenPoint(autocompleteContainer, OnlineMapsInput.mousePosition)) return;

            if (autocompleteContainer != null) autocompleteContainer.gameObject.SetActive(false);
        }

        /// <summary>
        /// This method is called when the autocomplete request is completed.
        /// </summary>
        /// <param name="response">Response string</param>
        private void OnAutocompleteComplete(string response)
        {
            if (autocompleteContainer == null || autocompleteItemPrefab == null) return;
           
            OnlineMapsGooglePlacesAutocompleteResult[] results = OnlineMapsGooglePlacesAutocomplete.GetResults(response);
            if (results == null || results.Length == 0)
            {
                autocompleteContainer.gameObject.SetActive(false);
                return;
            }
           
            autocompleteContainer.gameObject.SetActive(true);
            foreach (Transform t in autocompleteContainer) Destroy(t.gameObject);
           
            float y = 0;
           
            foreach (OnlineMapsGooglePlacesAutocompleteResult result in results)
            {
                GameObject item = Instantiate(autocompleteItemPrefab);
                item.transform.SetParent(autocompleteContainer, false);
                item.GetComponentInChildren<Text>().text = result.description;
                item.GetComponentInChildren<Button>().onClick.AddListener(() =>
                {
                    inputField.text = result.description;
                    Search();
                    inputField.ActivateInputField();
                });
               

                RectTransform rectTransform = item.GetComponent<RectTransform>();
                rectTransform.anchoredPosition = new Vector2(0, -y);
                y += rectTransform.rect.height;
            }
           
            RectTransform containerRectTransform = autocompleteContainer.GetComponent<RectTransform>();
            containerRectTransform.sizeDelta = new Vector2(containerRectTransform.sizeDelta.x, y);
        }

        /// <summary>
        /// This method is called when the geocoding request is completed.
        /// </summary>
        /// <param name="response">Response string</param>
        private void OnGeocodingComplete(string response)
        {
            OnlineMapsGoogleGeocodingResult[] results = OnlineMapsGoogleGeocoding.GetResults(response);
            if (results == null || results.Length == 0)
            {
                Debug.Log(response);
                return;
            }
            SetResultInScrollView(results);
            //OnlineMapsGoogleGeocodingResult r = results[0];
            //map.position = r.geometry_location;

            //Vector2 center;
            //int zoom;
            //OnlineMapsUtils.GetCenterPointAndZoom(new[] { r.geometry_bounds_northeast, r.geometry_bounds_southwest }, out center, out zoom);
            //map.zoom = zoom;

            //if (marker == null) marker = OnlineMapsMarkerManager.CreateItem(r.geometry_location, r.formatted_address);
            //else
            //{
            //    marker.position = r.geometry_location;
            //    marker.label = r.formatted_address;
            //}
        }
        private void SetResultInScrollView(OnlineMapsGoogleGeocodingResult[] results)
        {
            int index = 0;
            int resultCount = results.Length;
            if (resultCount == 0) return;
            LatteryResults = results;
            foreach (OnlineMapsGoogleGeocodingResult res in results)
            {
               GameObject go= Instantiate(autocompleteItemPrefab, autocompleteContainer);
                Text[] textChildren = go.GetComponentsInChildren<Text>();
                textChildren[0].text = res.formatted_address;
                textChildren[1].text = res.geometry_location.ToString();
                textChildren[2].text = index.ToString();
                index++;
                firstItem = go.transform.GetChild(2);
                itemButton = firstItem.GetComponent<Button>();
                itemButton.onClick.AddListener(() => OnItemButtonClicked(go));
            }
        }
        void OnItemButtonClicked(GameObject item)
        {
            Debug.Log("index: " + int.Parse(item.transform.GetChild(3).GetComponentInChildren<Text>().text));
            int ind=int.Parse( item.transform.GetChild(3).GetComponentInChildren<Text>().text);
            OnlineMapsGoogleGeocodingResult r = LatteryResults[ind];
            map.position = r.geometry_location;

            Vector2 center;
            int zoom;
            OnlineMapsUtils.GetCenterPointAndZoom(new[] { r.geometry_bounds_northeast, r.geometry_bounds_southwest }, out center, out zoom);
            map.zoom = zoom;

            if (marker == null) marker = OnlineMapsMarkerManager.CreateItem(r.geometry_location, r.formatted_address);
            else
            {
                marker.position = r.geometry_location;
                marker.label = r.formatted_address;
            }
            scrollViewSearchHandlr.SetActive(false);
           
            OnlineMapsGoogleDirections request = new OnlineMapsGoogleDirections
            (
                googleAPIKey,
                MapHald.GetComponent<MarkerAtBottom>().locationMarker.position, // FROM (string or Vector2)
                marker.position // TO (string or Vector2)
            );

            // Specifies that search results must be sent to OnFindDirectionComplete.
            request.OnComplete += OnFindDirectionComplete;

            request.Send();
        }
        public void SettingResult()
        {
            OnlineMapsGoogleGeocodingResult r = LatteryResults[Index_Result_Selected];
            map.position = r.geometry_location;

            Vector2 center;
            int zoom;
            OnlineMapsUtils.GetCenterPointAndZoom(new[] { r.geometry_bounds_northeast, r.geometry_bounds_southwest }, out center, out zoom);
            map.zoom = zoom;

            if (marker == null) marker = OnlineMapsMarkerManager.CreateItem(r.geometry_location, r.formatted_address);
            else
            {
                marker.position = r.geometry_location;
                marker.label = r.formatted_address;
            }
        }

        /// <summary>
        /// This method is called when the input field text is changed.
        /// </summary>
        public void OnInputChanged()
        {
            if (!useAutocomplete) return;
            if (!OnlineMapsKeyManager.hasGoogleMaps) return;
           
            if (inputField.text.Length < 3)
            {
                if (autocompleteContainer != null) autocompleteContainer.gameObject.SetActive(false);
                return;
            }

            OnlineMapsGooglePlacesAutocomplete.Find(inputField.text).OnComplete += OnAutocompleteComplete;
        }

        /// <summary>
        /// This method is called when the search button is pressed.
        /// </summary>
        public void Search()
        {
            scrollViewSearchHandlr.SetActive(true);
            foreach (Transform child in autocompleteContainer)
            {
                // Destroy the child GameObject
                Destroy(child.gameObject);
            }
            if (!OnlineMapsKeyManager.hasGoogleMaps)
            {
                Debug.LogWarning("Please enter Map / Key Manager / Google Maps");
                return;
            }

            if (inputField == null) return;
            if (inputField.text.Length < 3) return;

            string locationName = inputField.text;

            OnlineMapsGoogleGeocoding request = new OnlineMapsGoogleGeocoding(locationName, OnlineMapsKeyManager.GoogleMaps());
            request.OnComplete += OnGeocodingComplete;
            request.Send();
        }

        /// <summary>
        /// Shows the autocomplete container.
        /// </summary>
        private void ShowAutocomplete()
        {
            if (!useAutocomplete) return;
            if (autocompleteContainer == null) return;
            if (autocompleteContainer.transform.childCount == 0) return;
           
            autocompleteContainer.gameObject.SetActive(true);
        }

        private void Start()
        {
            if (map == null) map = OnlineMaps.instance;
           
            EventTrigger trigger = inputField.gameObject.AddComponent<EventTrigger>();
            EventTrigger.Entry lostFocusEntry = new EventTrigger.Entry {eventID = EventTriggerType.Deselect};
            lostFocusEntry.callback.AddListener((data) => { HideAutocomplete(); });
            trigger.triggers.Add(lostFocusEntry);
           
            EventTrigger.Entry gainFocusEntry = new EventTrigger.Entry {eventID = EventTriggerType.Select};
            gainFocusEntry.callback.AddListener((data) => { ShowAutocomplete(); });
            trigger.triggers.Add(gainFocusEntry);
        }

        private void Update()
        {
            EventSystem eventSystem = EventSystem.current;
            if ((OnlineMapsInput.GetKeyUp(KeyCode.KeypadEnter) || OnlineMapsInput.GetKeyUp(KeyCode.Return)) && eventSystem.currentSelectedGameObject == inputField.gameObject)
            {
                Search();
            }
        }
        private void OnFindDirectionComplete(string response)
        {
            // Get the result object.
            OnlineMapsGoogleDirectionsResult result = OnlineMapsGoogleDirections.GetResult(response);

            // Check that the result is not null, and the number of routes is not zero.
            if (result == null || result.routes.Length == 0)
            {
                Debug.Log("Find direction failed");
                Debug.Log(response);
                return;
            }

            // Showing the console instructions for each step.
            foreach (OnlineMapsGoogleDirectionsResult.Leg leg in result.routes[0].legs)
            {
                foreach (OnlineMapsGoogleDirectionsResult.Step step in leg.steps)
                {
                    Debug.Log(step.string_instructions);
                }
            }

            // Create a line, on the basis of points of the route.
            OnlineMapsDrawingLine route = new OnlineMapsDrawingLine(result.routes[0].overview_polylineD, Color.green);

            // Add the line route on the map.
            map.drawingElementManager.Add(route);
        }
    }
}
on click search icon button  i attached Search() function
and here i more 1 problem the LocationMarker doesn't present on the map !!!! ??
you suggest to replace the map with another map ?

Re: Camara Orbit Tremling

What are the origin and destination values?

Unfortunately, I didn't understand this:

and here i more 1 problem the LocationMarker doesn't present on the map !!!! ??
you suggest to replace the map with another map ?

Please rephrase it.

Kind Regards,
Infinity Code Team.

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