Hi Alex,
I think there's a problem with the smooth move map code, because no matter what I set the time to (3, 6, 15), the map always moves in 2 or 3 seconds. The code is based on GPS location change event. "Update Map" is unchecked for the GPS Location Changed script.
I have 3D markers which I see move with the map. They always seem to move at the same speed. I want to see them move sloooowly. I'm exaggerating here, but at this point I'm just trying to test different cases, and nothing seems to make a difference in the speed of the move. The map has already moved into position and yet the debug message on-screen is still ticking down the seconds.
Do you know what could be wrong, or how can a I slow down the map move?
public void OnLocationChanged(Vector2 position)
{
var tileOffset = TileOffset();
// from current map position
fromPosition = OnlineMaps.instance.position;
// to GPS position;
toPosition = position;
double realDistance = OnlineMapsUtils.DistanceBetweenPointsD(fromPosition, toPosition);
float distance = (float)realDistance * 1000f;
//StartCoroutine(DisplayMessage("moving: " + distance.ToString("f1") + " m"));
//_message = "moving: " + distance.ToString("f1") + " m";
_movingMessage = "moving: " + distance.ToString("f1") + " m";
// calculates tile positions
moveZoom = OnlineMaps.instance.zoom;
OnlineMaps.instance.projection.CoordinatesToTile(fromPosition.x, fromPosition.y, moveZoom, out fromTileX, out fromTileY);
OnlineMaps.instance.projection.CoordinatesToTile(toPosition.x, toPosition.y, moveZoom, out toTileX, out toTileY);
// if tile offset < 4, then start smooth movement
if (tileOffset < 4)
{
// set relative position 0
angle = 0;
// start movement
isMovement = true;
stopwatch.Reset();
stopwatch.Start();
}
else // too far
{
OnlineMaps.instance.position = toPosition;
}
}
private void Update()
{
// if not movement then return
if (!isMovement)
return;
// update relative position
angle += Time.deltaTime / time; // time = 3, 6, or 15 seconds, but always moves map in what seems like 2 or 3 seconds
if (angle > 1)
{
// stop movement
isMovement = false;
angle = 1;
}
else
{
_message = _movingMessage + " in " + (stopwatch.ElapsedMilliseconds / 1000).ToString() + " seconds";
}
// Set new position
double px = (toTileX - fromTileX) * angle + fromTileX;
double py = (toTileY - fromTileY) * angle + fromTileY;
OnlineMaps.instance.projection.TileToCoordinates(px, py, moveZoom, out px, out py);
OnlineMaps.instance.SetPosition(px, py);
}
Edit: Distance being moved is not much, typically about 5 to 10 meters.