Topic: Positioning Hot Spots by location

Positioning Hot Spots by location

When you have locations where the current and target panoramas are located, using uPano API you can convert the location to pan and tilt.

Example:

using System;
using InfinityCode.uPano;
using InfinityCode.uPano.HotSpots;
using UnityEngine;

public class CreateHotSpotByLocation : MonoBehaviour
{
    public double panoLongitude;
    public double panoLatitude;
    public float panoAltitude;

    public double hotSpotLongitude;
    public double hotSpotLatitude;
    public float hotSpotAltitude;

    public GameObject hotSpotPrefab;
    private HotSpot hotSpot;

    private void Start()
    {
        HotSpotManager hotSpotManager = GetComponent<HotSpotManager>();
        hotSpot = hotSpotManager.Create(0, 0, hotSpotPrefab);
        UpdatePosition(hotSpot, hotSpotLongitude, hotSpotLatitude, hotSpotAltitude);
    }

    private void UpdatePosition(HotSpot hotSpot, double longitude, double latitude, float altitude)
    {
        double tx1, tx2, ty1, ty2;
        GeoHelper.CoordinatesToTile(panoLongitude, panoLatitude, 20, out tx1, out ty1);
        GeoHelper.CoordinatesToTile(longitude, latitude, 20, out tx2, out ty2);

        double distance = GeoHelper.Distance(panoLongitude, panoLatitude, longitude, latitude) * 1000;

        float pan = 90 + (float) MathHelper.Angle2D(tx1, ty1, tx2, ty2);
        float tilt = 0;

        float offset = altitude - panoAltitude;
        if (Math.Abs(offset) > float.Epsilon)
        {
            tilt = (float)Math.Atan2(offset, distance) * Mathf.Rad2Deg;
        }

        hotSpot.SetPanTilt(pan, tilt);
    }
}

2 (edited by gbo10001 2020-06-18 16:11:34)

Re: Positioning Hot Spots by location

hi i put it in the code but the hotspot is following the camera wherever i go. i want the the hotspot stay at it's location. how can i do that?

Re: Positioning Hot Spots by location

Hello.

Unfortunately, I did not understand the description of your problem.
Here is the video that I have when using this script:
https://www.dropbox.com/s/e5tc5qm7em0ub … 5.mp4?dl=0
Please explain your problem in more detail.