Topic: Tile To Coordinates with float zoom
Hi, I am making an app that shows some pois on the map and then draws a circle around each poi with its range (The user has to be inside the range to interact with it).
The circles have a fixed radius that has to be refreshed accordingly with the zoom of the map, I use a code that I found in this post:
http://forum.infinity-code.com/viewtopi … 3651#p3651
My code:
private void UpdatePoiRangeCircle(MyMarker myMarker)
{
OnlineMaps mapInstance = OnlineMaps.instance;
Vector2 distanceBetweenTileCorners = OnlineMapsUtils.DistanceBetweenPoints(mapInstance.topLeftPosition, mapInstance.bottomRightPosition);
float radiusInPixels = (myMarker.poi.range / 1000f) * OnlineMapsTileSetControl.instance.sizeInScene.x / distanceBetweenTileCorners.x;
float r = radiusInPixels / OnlineMapsUtils.tileSize;
float step = 360f / poiCircleSegments;
double x, y;
myMarker.OMmarcador.GetPosition(out x, out y);
OnlineMapsProjection projection = mapInstance.projection;
projection.CoordinatesToTile(x, y, mapInstance.zoom, out x, out y);
for (int i = 0; i < poiCircleSegments; i++)
{
double px = x + Mathf.Cos(step * i * Mathf.Deg2Rad) * r;
double py = y + Mathf.Sin(step * i * Mathf.Deg2Rad) * r;
// Old way (Online Maps v2.3):
// OnlineMapsUtils.TileToLatLong(px, py, map.zoom, out px, out py);
projection.TileToCoordinates(px, py, mapInstance.zoom, out px, out py);
myMarker.poiCircle.points[i] = new Vector2((float)px, (float)py);
}
}
This works fine but the problem is that when zooming in or out the circle doesn't update correctly until it reaches an int value of the zoom.
I attached a video of what's happening.
Is there any way to get the coordinates from tile position using a float zoom instead of an int zoom?