Thanks for the response.
What i really need for those gameobjects are:
- follow the map when it's moving (so it stay at the exact gps location & altitude)
- keep the same size proportionnally to the map zoom lvl (my gameObject should grow in size when the user zoom on the map)
- be disabled when out of the square map view
I think i could work with that. Is it an overkill to use 3D marker for this behaviour ?
Now correct me if i'm wrong, but to implement this behaviour myself, i need to :
1) position my gameobject based on its GPS location. I will use this function :
/// <summary>
/// Return the World position of a GpsCoordinates position
/// </summary>
/// <param name="pos">GpsCoordinates position to convert</param>
public static Vector3 GetWorldPositionWithAltitude(GpsCoordinates pos)
{
Vector3 p = OnlineMapsTileSetControl.instance.GetWorldPosition(pos.Longitude, pos.Latitude);
OnlineMaps.instance.UpdateCorners();
double tlx, tly, brx, bry;
OnlineMaps.instance.GetCorners(out tlx, out tly, out brx, out bry);
p.y = (float)pos.Altitude;
p.y += OnlineMapsElevationManagerBase.GetUnscaledElevation(pos.Longitude, pos.Latitude, tlx, tly, brx, bry);
p.y *= OnlineMapsElevationManagerBase.GetBestElevationYScale(tlx, tly, brx, bry);
p.y *= OnlineMaps.instance.transform.localScale.x;
return p;
}
Then to keep the proper position i would need to subscribe to
OnlineMapsTileSetControl.instance.OnMeshUpdated
and use the function above to reposition my gameobject.
I also need to subscribe to
OnlineMapsTileSetControl.instance.OnSmoothZoomProcess
to keep a proper scale for my gameobject. I think i should store the original scale of the gameobject for a given zoom lvl and adapt it to the current zoom level. Something like :
/// <summary>
/// Zoom, when the scale = 1.
/// </summary>
public int defaultZoom = 20;
And then each time OnSmoothZoomProcess is called :
float originalScale = 1 << defaultZoom;
float currentScale = 1 << OnlineMaps.instance.zoom;
float scale = currentScale / originalScale;
transform.localScale = new Vector3(scale, scale, scale);
I'm not sure that my pieces of codes are correct. I also don't now if i'm missing some important stuff