mapbox / mapbox-sdk-cs

C# libraries for Mapbox API layer
https://mapbox.github.io/mapbox-sdk-cs/
Other
20 stars 11 forks source link

in Unity3d,Can I get the lat/lon or meter where whe mouse input #70

Closed veyvin closed 7 years ago

veyvin commented 7 years ago

what I get is the tile's ID, but I want to get the lat/lon or Meter in terrain .

david-rhodes commented 7 years ago

@veyvin Are you raycasting to a specific point on the terrain? Is your position in world space? If so, use Transform.GetGeoPosition() (extension method in VectorExtensions) as reference.

Something like this should work:

        public static Vector2d GetGeoPosition(this Vector3 v, Vector2d refPoint, float scale = 1)
        {
            var pos = refPoint + (v / scale).ToVector2d();
            return Conversions.MetersToLatLon(pos);
        }
veyvin commented 7 years ago

@david-rhodes 3Q