OnlineMapsTilesetDrawingMode.overlay sorta works (I do not appear to be on 2.5.5.1, that field doesn't exist), except that when I move the marker around, the polygon that is anchored to it doesn't update when I drag the marker around, only when I zoom in and out.
This is being called from LateUpdate():
private int lastZoom = -1;
private void UpdateRadioLocations()
{
float step = 360f / SEGMENTS;
double x, y;
Vector2 distance = OnlineMapsUtils.DistanceBetweenPoints(OnlineMaps.instance.topLeftPosition, OnlineMaps.instance.bottomRightPosition);
float convertToKm = 1;
float scaleX = convertToKm / distance.x * OnlineMaps.instance.tilesetSize.x;
float scaleY = convertToKm / distance.y * OnlineMaps.instance.tilesetSize.y;
float scale = (scaleX + scaleY) / 2;
foreach (RadioPlacement radio in radioList)
{
if (radio.marker.position != radio.lastPosition || lastZoom != zoom) //this check fails on marker drag
{
lastZoom = zoom;
float r = radio.radius * 2 / OnlineMapsUtils.tileSize * scale;
radio.lastPosition = radio.marker.position;
radio.marker.GetPosition(out x, out y);
OnlineMapsProjection projection = OnlineMaps.instance.projection;
projection.CoordinatesToTile(x, y, OnlineMaps.instance.zoom, out x, out y);
for (int i = 0; i < SEGMENTS; i++)
{
double px = x + Mathf.Cos(step * i * Mathf.Deg2Rad) * r;
double py = y + Mathf.Sin(step * i * Mathf.Deg2Rad) * r;
projection.TileToCoordinates(px, py, OnlineMaps.instance.zoom, out px, out py);
radio.points[i] = new Vector2((float)px, (float)py);
}
OnlineMaps.instance.Redraw();
}
}
}
There's no reason changing the drawing mode should cause the marker's position to not update properly.